Django:尝试domain.com/admin时会给404一个旧的不存在的urls文件 [英] Django: when trying domain.com/admin gives 404 with an old unexisting urls file
问题描述
我在某个时候有一个看起来像这样的urls文件:
I had at some point an urls file that looked like that:
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
url(r'^$', 'girls.views.home', name = 'home'),
url(r'^registerasboy$', 'girls.views.regb', name= 'regb'),
#url(r'^registerasgirl$', 'girls.views.reg', name= 'regg'),
url(r'^thankyou$', 'girls.views.thankyou', name= 'thankyou'),
url(r'^newchick$', 'girls.views.newchick', name= 'newchick'),
url(r'^chicks$', 'girls.views.chicks', name= 'chicks'),
#url(r'^thankyou$', 'generalsettings.views.thankyou', name = 'thankyou'),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
#url(r'^reg$', 'generalsettings.views.home'),
# Uncomment the next line to enable the admin:
#(r'^admin/', include(admin.site.urls)),
#(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
)
该站点正常运行.我没有管理员.所以我决定取消注释管理行,并且会收到错误404
And the site worked. I didn't have an admin. So i decided to uncomment the admin line, and i would get error 404
找不到页面(404)
请求方法:GET
请求网址: http://chicklister.com/admin
Page not found (404)
Request Method: GET
Request URL: http://chicklister.com/admin
Using the URLconf defined in chick.urls, Django tried these URL patterns,
in this order:
^$ [name='home']
^registerasboy$ [name='regb']
^thankyou$ [name='thankyou']
^newchick$ [name='newchick']
^chicks$ [name='chicks']
^/(?P<path>.*)$
The current URL, admin, didn't match any of these.
这很奇怪,因为此处缺少管理行.现在,我将网址进一步更新为:
which is weird, because the admin line is missing here. Now, i Updated further my urls to:
urlpatterns =模式('',
(r'^ admin/',include(admin.site.urls)),)
urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),)
但是我得到了管理员:
Using the URLconf defined in chick.urls, Django tried these URL patterns,
in this order:
^$ [name='home']
^registerasboy$ [name='regb']
^thankyou$ [name='thankyou']
^newchick$ [name='newchick']
^chicks$ [name='chicks']
^/(?P<path>.*)$
The current URL, admin, didn't match any of these.
但是,根据打印的url文件中的行,其他任何url作品(例如www.domain.com/thankyou)也可以
and yet, any other url works such as www.domain.com/thankyou according to the lines in the printed url file
这怎么可能?好像已经在某个地方记住了它.
How is this possible? It seems like it has been remembered somewhere.
我执行的步骤: 在www的整个文件夹中搜索"registerasboy",然后不再返回任何内容. 我更改了模板上的文本,以确保我要更新正确的副本. 我在settings.py中有以下设置:
Steps i did: searched the whole folder in www for 'registerasboy' and returned nothing anymore. i changed the text on the template, to make sure i am updating the right copy. i have the following settings in the settings.py:
ROOT_URLCONF ='urls' 我注意到它实际上并没有做任何事情,因为一开始它是chic.urls
ROOT_URLCONF = 'urls' which i noticed didn't really do anything, since in the beginning it was chic.urls
我在做什么错?我似乎甚至都没有包含此类内容的文件...
What am i doing wrong? i don't seem to even a file with such content anymore...
推荐答案
只是在黑暗中开枪:
您是否在INSTALLED_APPS中添加了管理员,执行了syncdb并重新启动了服务器?
Did you add the admin in your INSTALLED_APPS, do a syncdb and restarted the server ?
如果将Apache与mod_wsgi一起使用,则重新启动服务器很有用.它不会检测到代码中的更改,因此您需要手动重新加载它.
Restarting the server is useful if you use Apache with mod_wsgi. It does not detect the changes in the code so you need to reload it manually.
开发服务器自动重新加载代码.
The development server reloads code automatically.
这是有关此问题的完整信息: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
Here is the complete information about this issue : http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
这篇关于Django:尝试domain.com/admin时会给404一个旧的不存在的urls文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!