I added a new ImageField in my models.py:
class User(AbstractUser):
[more_fields_here]
profile_picture = models.ImageField(upload_to='profile_pictures', null=True)
I ran python manage.py makemigrations and then python manage.py migrate without any errors.
But when I run my application I am getting:
ProgrammingError at column authentication_user.profile_picture does not exist
I checked in the Postgres database and the column profile_picture does not exist.
I deleted the migrations and tried again, but I am still getting the same error.
In the migrations/0001_initial.py there is the line:
('profile_picture', models.ImageField(null=True, upload_to='profile_pictures')),
But why does the column not exist in the table?
It looks like it was something messed with migrations, it's not recommended to modify migration files manually. Django stores information which migrations were already applied, if you modify 0001 migration which is already applied and run migrate again those modifications won't be applied. Of course I don't know if this exactly what happened to you, but it looks like profile_picture field was added after 0001 was applied.
The easiest way to fix this (without rollbacking any migrations):
profile_picture from 0001 migrationmakemigrations again (0002 with new field profile_picture should be created)migrateIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With