所以,我喜欢django,但对于简单的网站来说,它不是那么用户友好。而且,我安装了django cms 2(最后一个稳定版),一个make all in tutorial。同时,我想要多语言网站。
但是,我收到404错误页面。请检查我的settings.py和urls.py.我做错了什么?为什么网站不会自动将我重定向到我们?谢谢你的帮助。
错误文字
Using the URLconf defined in hackcoin.urls, Django tried these URL patterns, in this order:
^media/(?P<path>.*)$
^static\/(?P<path>.*)$
^en-us/
The current URL, , didn't match any of these.
settings.py
MIDDLEWARE_CLASSES = (
...
'cms.middleware.language.LanguageCookieMiddleware',
)
LANGUAGES = [
('en', 'English'),
('ru', 'Russian'),
]
LANGUAGE_CODE = 'en-us'
urls.py
from django.conf.urls.defaults import *
from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.conf import settings
admin.autodiscover()
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('cms.urls')),
)
if settings.DEBUG:
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
url(r'', include('django.contrib.staticfiles.urls')),
) + urlpatterns
答案 0 :(得分:1)
尝试设置LANGUAGE_CODE =“en”并确保安装了django语言环境中间件