I have one problem with Django Framework.
I changed one model insert this:
masterweb_link = models.CharField(_('masterweb_link'), help_text=_('link to MasterWeb tour'), max_length=300, null = True, blank = True)
After that I was this:
– python manage.py syncdb
and db_application was changed and now I can work with new column in admin panel.
On my local-pc everything is fine when i tried to check it.
But, when I try to do this on host, after all my actions model modify and database too, but Django admin site not displaying new column.
I have no errors when i do all my actions! Please help.
As Daniel Roseman mentioned,
syncdbdoes not modify existing tables.To do this, you need to use
southhttp://south.aeracode.org/A very quick walk through for converting your existing application to use
south. First, you can install it usingeasy_installby typingeasy_install South. If you wish to install it from Mercurial or from a snapshot tar.gz, they have instructions provided here.Once it is installed, you need to convert your existing application to use
south. In your application’ssettings.pyfile, addsouthtoINSTALLED_APPSand then rerunpython manage.py syncdb. All this is doing is adding data tables for thesouthapplication. It is not doing anything with your model yet.Now, you want to undo the change you made in your original post. Go back to what is was. We will be making that change in a few minutes, but first, we need to tell
southwhat your application looks like now.python manage.py convert_to_south <appname>Replace<appname>with your application’s name. This is going to create the initial migration file for your application.Commit these changes to your version control (or distribute the application via your normal process to your other developers). It should be a new folder named
migrationsin your application directory. You will need to commit/distribute all files that appear in this folder.One time thing: Everywhere that your application is installed needs to run this command to convert to using south as well.
python manage.py migrate <appname> 0001 --fakeAccording to the documentation, this is required because the initial migration that convert_to_south makes will try and create all the existing tables; instead, you tell South that it’s already applied using--fake, so the next migrations apply correctly.Now, we are going to make your change. Re-edit your model to make the change you want. Save the model.
Run this command:
python manage.py schemamigration <appname> --auto. South will analyze your models and how they have changed and create a migration script. This is why we needed to revert your changes back to their original state. Otherwise,southwouldn’t know what it from migrating from.When it is complete, run
python manage.py migrate <appname>. Again, commit or distribute themigrationsfolder. Each location this is deployed will need to runpython manage.py migrate <appname>.In the future when you make schema changes you will run
python manage.py schemamigration <appname> --autoto create the migration script andpython manage.py migrate <appname>to install the changes.I also recommend glancing at the documentation for other things
southis capable of handling during migrations. The above should get you started though. South’s documentation is location here.