100
From Django 1.7 onwards
Django has built in support for migrations – take a look at the documentation.
For Django 1.6 and earlier
Django doesn’t support migrations out of the box. There is a pluggable app for Django that does exactly that though, and it works great. It’s called South.
14
Django currently does not do this automatically. Your options are:
- Drop the table from the database, then recreate it in new form using syncdb.
- Print out SQL for the database using
python manage.py sql (appname)
, find the added line for the field and add it manually usingalter table
SQL command. (This will also allow you to choose values of the field for your current records.) - Use South (per Dominic’s answer).
- [Django]-Execute code when Django starts ONCE only?
- [Django]-Django 1.10.1 'my_templatetag' is not a registered tag library. Must be one of:
- [Django]-What is choice_set in this Django app tutorial?
11
Follow these steps:
- [Django]-How can I chain Django's "in" and "iexact" queryset field lookups?
- [Django]-Pycharm error Django is not importable in this environment
- [Django]-Django: OperationalError No Such Table
8
As suggested in top answer, I tried using South, and after an hour of frustration with obscure migration errors decided to go with Django Evolution instead.
I think it’s easier to get started with than South, and it worked perfectly the first time I typed ./manage.py evolve --hint --execute
, so I’m happy with it.
- [Django]-Why does my Django admin site not have styles / CSS loading?
- [Django]-VueJS + Django Channels
- [Django]-Django – how to create a file and save it to a model's FileField?
2
Havent used django in a while, but i seem to remember that syncdb does perform alter commands on db tables. you have to drop the table then run again and it will create again.
edit: sorry does NOT perform alter.
- [Django]-How to save pillow image object to Django ImageField?
- [Django]-Python/Django: how to assert that unit test result contains a certain string?
- [Django]-Django in / not in query
1
In django 1.6
-
At first we have run –
python manage.py sql <app name>
-
Then we have to run –
python manage.py syncdb
- [Django]-How do I include related model fields using Django Rest Framework?
- [Django]-Django: How to get related objects of a queryset?
- [Django]-How to mix queryset results?
0
If you run Django with Apache and MySQL, restart apache after making migration with makemigrations.
- [Django]-How can I return HTTP status code 204 from a Django view?
- [Django]-Django-tables2: How to use accessor to bring in foreign columns?
- [Django]-Handle `post_save` signal in celery