Django.db.utils.ProgrammingError: column tickets_ticket.track_code does not exist

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 migrate app_name 0001

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

That is wrong command which is you used to migrate.

Migrate using below 3 commands:

python makemigrations appname

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

python migrate

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

Back to Top