Django管理员间接地返回404模型编辑 [英] Django Admin Intermittently Returning 404 On Model Edit

查看:104
本文介绍了Django管理员间接地返回404模型编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Django管理员来维护一些导出到我们网站的数据。有时,当点击标准更改列表视图以获取模型编辑表单而不是路由到正确的页面时,我们将获得Django 404页面/模板。

We're using the Django Admin to maintain some data that's exported to a few of our sites. Sometimes when clicking through the standard changelist view to get a model edit form instead of being routed to the correct page we're getting the Django 404 page/template.

发生在某种程度上,我们可以通过重新加载三次来重现它:

It was happening somewhat sporatically, and we could for a while reproduce it by reloading three times:


  • 首先F5:404
  • $ b $第二F5:404
  • 第三F5:对象更改表单正确加载

  • First F5: 404
  • Second F5: 404
  • Third F5: Object change form loads correctly

但是最近它一直在返回404更多的频率。当我们反弹apache(优雅),并且更多(再次似乎似乎)有更多的请求时,似乎可以减少返回404的可能性。

But lately it's been returning 404 more often than not. It seems to reduce the odds of returning 404 when we bounce apache (gracefully) and gets worse (again, seemingly) with more requests.

快速运行Django 1.2.1 -CGI / MySQL 5.1.x

Running Django 1.2.1 on Fast-CGI/MySQL 5.1.x

FWIW,我无法在我的虚拟机上重现问题,但是我正在运行mod_wsgi,并将Debug = True设置为设置。否则代码和数据库是一样的。

FWIW, I can't reproduce the problem on my VM, but I'm running mod_wsgi there and have Debug=True set in the settings. Otherwise the code and database is identical.

推荐答案

我有同样的问题。我的解决方案是将我的电话转到 admin.site.register() admin.py 。当DEBUG设置为false时,您的模型会被加载,因此注册呼叫并不总是被完成。显然, admin.py 始终在init时加载。

I had this same problem. The solution for me was to move my calls to admin.site.register() to admin.py. With DEBUG set to false, your models are lazily loaded, so the registration calls don't always get made. Apparently admin.py is always loaded at init time, however.

这篇关于Django管理员间接地返回404模型编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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