我已经将django-registration与django-cms集成在一起。我的网站有多种语言django-cms,有两种语言英语和法语。我在url-mapping中面临问题。由于django-cms有多种语言,因此它在域名后附加了语言代码。在django-registration中,它将这样的URL视为404。
下面是流程,点击我已经明确设置为http://localhost:8000/accounts/register/
的注册按钮并正确显示注册页面,但在成功完成注册后,它会重定向到http://localhost:8000/en/accounts/register/complete/
,其中附加了语言代码用url和django-registration说找不到页面。如果我从url手动删除语言代码,它可以正常工作。
有人能帮助我吗?
项目的url.py。
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^', include('cms.urls'), name="home"),
url(r'^news/', include('multilingual_news.urls')),
url(r'^search/', include('haystack.urls')),
url(r'^member/',include('openerp_member.urls')),
(r'^accounts/',include('registration.backends.default.urls')),
)
答案 0 :(得分:2)
您需要为Django-Registration添加AppHook。所以我做的是:
创建相应的cms_apps.py
:
from cms.app_base import CMSApp from cms.apphook_pool import apphook_pool from django.utils.translation import ugettext_lazy as _ class RegistrationApphook(CMSApp): name = _("RegistrationApphook") urls = ["registration.backends.hmac.urls"] apphook_pool.register(RegistrationApphook)
创建“帐户”
RegistrationApphook
(您可能需要重新启动服务器才能使其可用)现在您应该可以访问这些网址了。