27👍
As noted in the documentation syncdb
doesn’t add columns to existing tables, it only creates new tables.
I suggest running
python manage.py sqlall <your_app>
Looking at the sql it outputs for the table you’re changing, and then running
python manage.py dbshell
in order to manually issue an ALTER TABLE
command.
In future, you might like to use a migration tool like South.
3👍
There are two possibilities that to get this error 1) You added extra field to model after doing the syncdb. 2) you added new class to model.py file in django.
Solution for this is:
First install south by using command
for windows: **easy_install south** //for that you need to go to the script folder of python folder in c drive.
for linux: **sudo easy_install south**
Then follow the steps which are included here migration tutorials
step1- python manage.py schemamigration your_app_name –initial
step-2 python manage.py migrate your_app_name
Hope this will help you.
- DRF: Validate nested serializer data when creating, but not when updating
- Django – Add field to queryset to store computation results
- Django-rest-framwork got AttributeError when attempting to get a value for field
0👍
As of 1.7 migrations within Django replaces South.
Create a new set of migration instructions by running the following command in terminal:
$ python manage.py makemigrations
Check the output in the migration folder it creates to make sure they make sense then run the following terminal command to complete the migrations:
$ python manage.py migrate
That’s it.
Running migrations this way allows others to implement the same migrations instead of having to manually implement db changes on every machine using the code. On the new machine all they have to run is:
$ python manage.py migrate
- Uploading images using Django Admin?
- Testing several IntegrityErrors in the same Django unittest test case