4👍
It looks like may be an issue with migration.
Running ./manage.py schemamigration research --auto
shows that most of the fields don’t have any defaults specified.
Next, you then run ./manage.py schemamigration research --init
followed by ./manage.py migrate research
This worked for me after I created the table:
python manage.py migrate --run-syncdb
NOTE: Don’t forget to run python makemigrations first, i.e. python manage.py makemigrations {name of the app where patients model is}
Helpful tips: There is a table generated by
django
calleddjango_migrations
which keeps track of what migrations have
been
applied. If you delete yourmigrations
, re-generate them and try to
migrate
without deleting the records from the table, thendjango
will
think it already applied them. You should never delete your
migrations, as it will cause django to get confused.You can skip the migrations step if you are actively developing If you are actively developing and want to skip the entire
migrations
system you can, but once you start usingmigrations
, never delete
them. Here is what I use while developing a new project:dropdb mydb && createdb mydb && python manage.py migrate --run-syncdb && python manage.py loaddata initial
First, it drops the database and all data. Then it creates an empty
one. The--run-syncdb
generates the schema and theloaddata
loads
data from a fixtures file.So, if you are still developing and can delete all your data and move
what you care about to a fixtures file, then you can delete all your
migration folders. You then can run the command above each time you change your
model.