[Answer]-Cannot save modelform to database in django

1👍

The error message seems quite clear: you have defined a model in django but forgot to create the model’s table in your database. In django < 1.7, the builtin management command syncdb (https://docs.djangoproject.com/en/1.6/ref/django-admin/#syncdb) will create the table if it doesn’t exist, but you’ll have to manually take care of schema changes (if you add / remove / modify fields from an existing model), so I strongly advise you either use South (https://south.readthedocs.org/en/latest/) to handle schema and data migrations or just upgrade to django 1.7 which has builtin support for schema and data migrations.

As a side note: the good practice after a successfull post is to redirect (http://en.wikipedia.org/wiki/Post/Redirect/Get).

0👍

You have to create migrations and run them. I see that you are using Django 1.6.1 so you have to follow these steps:

Open your settings.py and check if you have ‘south’ on your INSTALLED_APPS (If not, follow this guide)

Open the terminal

Go to the root of your project (where there is a file called manage.py)

Run the following commands:

python manage.py syncdb
python manage.py schemamigration nameofyourapp --initial
python manage.py migrate nameofyourapp
python manage.py schemamigration nameofyourapp --auto

Leave a comment