Question

I have created my models in django and run manage.py syncdb

Everything was ok, until I added a new model in an existing app. When I run syncdb again, duplicated entries were inserted in auth_parmission table. Even for entry log from "admin" app.

I made a test to remove the new model, drop the database, create an empty one and run syncdb. This loaded my initial data from an existing fixture.

When I run "syncdb" again (without adding any new model), the same thing happened: duplicated entries were inserted in auth_permission table.

Any explanation of what's happening and how to avoid those duplicated entries?

Thanks

Was it helpful?

Solution

Most likely your initial data fixture includes entries from auth_permission. Django creates these initially during syncdb and then runs the fixtures. Your fixture then creates them again.

If you're running Django 1.3+, you can use --exclude auth with the dumpdata management command to create your fixtures. Otherwise, you'll need to either manually list all the apps/models that should be included (so that auth won't be by default) or manually edit the fixture afterwards and remove the auth entries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top