bytejunkie bytejunkie - 8 months ago 50
Python Question

django on a vps - getting "model is already registered" when restarting server

asked this question over the weekend, but for some reason all replies have died. started it again as i now have new information

when i restart apache on my vps, i get

the model "category" is already registered


i think this is because the object is getting discovered and registered twice.

i didn't think this would be an issue, it isn't in dev where i don't get these errors. also, i dont get the error the first time i run the server after a syncdb.

so upload code, syncdb, start apache, no error message. restart apache and the error message appears.

i can hide it, by commenting out the line that registers the model, but this means that the object doesn't appear in admin unless i uncomment the line and upload it after the admin site has loaded the first time.

this only appears to happen the first time after an apache reset, doesn't happen subsequent times.

anyone come across this before? using apache with mod_wsgi on debian, django 1.2.3

Answer Source

The error message suggests that model registration code is being repeated. Are you registering your models in the file? The recommended way is to write a separate file to register the models.