-1

I used postgresql and I want add a new field to my model:

track_code = models.CharField(max_length=32, verbose_name=_('کد رهگیری'), default=generate_rrr_unique_trackcode)

but after migrate i received this error:

django.db.utils.ProgrammingError: column tickets_ticket.track_code does not exist
LINE 1: SELECT (1) AS "a" FROM "tickets_ticket" WHERE "tickets_ticke...
                                                      

I used the command:

python3 manage.py migrate app_name 0001

and delete the last migration file and then try again but not working...

1
  • Check this answer. This may help you to overcome your problem. Commented Dec 21, 2022 at 8:13

1 Answer 1

0

That is wrong command which is you used to migrate.

Migrate using below 3 commands:

python manage.py makemigrations appname

python manage.py sqlmigrate appname 0001 #This value will generate after makemigrations. It can be either 0001, 0002 and so on

python manage.py migrate

Note: don't forget to delete that last migration.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks but I received same error after step two!
ok do one thing, delete all migrations file and db file and then try above commands
Thanks I had to delete my postgres database and create again and then migrate... this is worked!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.