Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我如何引用Django 1.5 URL中的;命名为;在包含的URL文件中?_Django_Django Templates - Fatal编程技术网

我如何引用Django 1.5 URL中的;命名为;在包含的URL文件中?

我如何引用Django 1.5 URL中的;命名为;在包含的URL文件中?,django,django-templates,Django,Django Templates,我的项目的主URL.py文件包含以下内容: url(r'^accounts/$', include('accounts.urls'), urlpatterns = patterns('accounts.views', url(r'^profile/$', 'accounts_profile', name='accounts_profile'), 在accounts.url.py中,我有以下内容: url(r'^accounts/$', include('accounts.urls

我的项目的主URL.py文件包含以下内容:

 url(r'^accounts/$', include('accounts.urls'),
urlpatterns = patterns('accounts.views',
    url(r'^profile/$', 'accounts_profile', name='accounts_profile'),
在accounts.url.py中,我有以下内容:

 url(r'^accounts/$', include('accounts.urls'),
urlpatterns = patterns('accounts.views',
    url(r'^profile/$', 'accounts_profile', name='accounts_profile'),
在我的base.html模板中,我有:

<li><a href="{% url 'accounts_profile' %}">Profile</a></li>

如果我将accounts\u profile url定义移动到main url.py,url就会工作。我记得这种风格的URL组织在以前的Django版本中工作;有什么改变了,或者我做错了什么吗?

去掉
url(r'^accounts/$),include('accounts.url'),
调用中的$

请注意,本例中的正则表达式没有$(字符串结尾匹配字符),但包含尾部斜杠


在这里,我想Django 1.5可以改变一切!感谢您的帮助!