Maintaining integrity of pk content in Django deployment

When you run syncdb in Django, the primary keys of the content types will be recalculated. If I create new models, the next time I run syncdb, the primary keys of the content types will be different.

If I have an application running in production, how can I update the database with new models and keep the integrity of the pks content type?

+2


a source to share


2 answers


Running syncdb

does not update the existing ContentType values ​​— they are stored in the database and are not changed. Therefore, the relationships that depend on them will not be affected.



New models, however, will receive new ContentType values ​​when syncdb runs, and there is currently no way to predict what this will be. As Ludwik points out, this issue is addressed in 1.2.

+2


a source


The issue is fixed in Django 1.2 (due out in two weeks) with natural keys .



+1


a source







All Articles