Skip to content Skip to sidebar Skip to footer

Django 1.6 Editing Userprofile Model With Existing Users

I have a django database with a custom user profile for the user model. The problem is that when I want to add new fields to my userprofile class, I get the error no such column, r

Solution 1:

Here is how to do it..

First install south

pip install south

Then add to your settings INSTALLED_APP list as -

   ...,
   'south',
   ...

What is south?.. Well south is a django app that helps you updating your database without having to rebuild it. Now initialise your models with-

python manage.py syncdb // this will create the south tables for migrations
python manage.py schemamigration <appname> --initial//  (once per app) this will create the initial model files in a migrations package
python manage.py migrate

Then every time you update your models just need to perform an update with -

python manage.py schemamigration <appname> --auto
python manage.py migrate <appname>

You can find the full documentation here - http://south.readthedocs.org/en/latest/tutorial/

Post a Comment for "Django 1.6 Editing Userprofile Model With Existing Users"