Reputation: 96
I added another field to my Listing()
model called highest_bid
. However, when I try to look at the listing model in the /admin
page I get the OperationalError
:
no such column: auctions_listing.highest_bid
After adding this field I tried using makemigrations
, but it said that there were no changes and I also tried using migrate
but that also said that there was nothing to migrate.
I also tried removing null=True
on the field but that did not change anything.
How do I add this field without getting an error?
models.py:
class Listing(models.Model):
...
highest_bid = models.FloatField()
# highest_bid = models.FloatField(null=True)
# they both returned the same error
Upvotes: 0
Views: 130
Reputation: 26
According to this answer you have to make sure you:
INSTALLED_APPS
inside settings.py
, otherwise makemigrations
will not check for changes in your models./manage.py makemigrations <app_name>
if your app doesn't have a migrations
module yet (i.e. it's going to be your app's 0001_initial.py
migration)If you can cross these two requirements off your list (i.e. you're doing subsequent changes to your models), then ./manage.py makemigrations
without any <app_name>
should simply work.
Upvotes: 1
Reputation: 132
how makemigrations
didn't add the changes, you have to find a way to implement make migrations and create a file in the migrations folder otherwise, your field will not be in the DB and you will keep seeing the same error
so try ./manage.py makemigrations your_app_name
Upvotes: 0