一个vps-获得“模型上的django已经被注册”重新启动服务器时 [英] django on a vps - getting "model is already registered" when restarting server

查看:180
本文介绍了一个vps-获得“模型上的django已经被注册”重新启动服务器时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在周末问这个问题,但由于某种原因,所有答复都已经死亡。再次启动它,因为我现在有新的信息

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

当我重新启动apache在我的vps,我得到

when i restart apache on my vps, i get

the model "category" is already registered

从init.py

我认为这是因为对象被发现和注册了两次。

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

我没有想到这会是一个问题,它不是在开发,我没有得到这些错误。还有,我没有得到错误,我第一次在syncdb运行服务器。

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.

所以上传代码,syncdb,启动apache,没有错误消息。重新启动apache并显示错误消息。

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.

这只会在apache重置后第一次发生,不会发生以后的时间。

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

以前有人遇到过吗?在debian上使用apache与mod_wsgi,django 1.2.3

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

推荐答案

错误消息表明模型注册码正在重复。你在models.py文件中注册你的模型吗?建议的方法是写一个单独的admin.py文件来注册模型。

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

这篇关于一个vps-获得“模型上的django已经被注册”重新启动服务器时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆