将Django 1.3与开发服务器一起使用
我尝试连接:http://127.0.0.1:8000/lang/en
答案是:
使用中定义的URLconf pruebas.urls,Django尝试了这些URL 模式,按此顺序:
- ^管理员/
- ^邮报/ $
- ^登录/ $
- ^郎/(ΔP\ W +)/ $
- ^ site_static /(ΔP。*)$
醇>当前网址与任何网址都不匹配 这些
from pruebas import settings
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'pruebas.views.home', name='home'),
# url(r'^pruebas/', include('pruebas.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
(r'^correo/$', 'mailclient.views.index'),
(r'^login/$', 'kusers.views.klogin'),
# Language change
(r'^lang/(?P<lang_code>\w+)/$', 'kusers.views.lang'),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),)
我认为这一行:
(r'^ lang /(?P \ w +)/ $','kusers.views.lang'),
会与“http://127.0.0.1:8000/lang/en”匹配,但似乎我错了。
提前致谢
kusers / views.py中的代码是:
def lang(request, lang_code):
request.session['django_language'] = lang_code
return HttpResponseRedirect( "/" )
解决。
问题不是urls.py配置。问题是'kuser'app文件夹estructure。
由于