2👍
I just ran into an issue like this. In my case, the problem was that I had installed, through pip, the stable version of the package that I was developing, and Django was importing the stable version rather than my development version. To check if this is the case with you, try adding a syntax error to models.py
. If makemigrations
doesn’t trigger the syntax error, then you’ll know that your version is not even being loaded by the python interpreter.
1👍
If your model is not inheriting from django model then, you will see aforementioned error. Make sure that your custom model inherits from django models.Model
, something like this.
from django.db import models
class Posts(models.Model):
...
- [Django]-Looking for read-write lock in Django using PostgreSQL, e.g., SELECT FOR SHARE
- [Django]-How to configure code completion for Django based projects in PyDev?
- [Django]-Django aggregation over annotated query
- [Django]-Changing package install order in Python
-3👍
Deleting the DB and creating new one will never work since it refer the previous migration files. Delete all previous migration files and pycache files except init. Then try running these.
python manage.py migrate --fake-initial
python manage.py makemigrations
python manage.py migrate
This worked for me
- [Django]-Encode ImageField in base64 and store it in DB instead of path of the image
- [Django]-Django admin ignores has_delete_permission
- [Django]-Django: Sum by date and then create extra field showing rolling average
- [Django]-Why is django.test.client.Client not keeping me logged in