tam*_*are 8 django django-urls django-registration django-1.4
我不知道这个问题是否与我将描述的问题相同,但它确实有相同的症状.不幸的是,在我写作时它仍然没有得到解决.
所以这是我的问题.我正在尝试将James Bennett的django-registration应用程序添加到我的django项目中.我已经完成了根据我的需求配置它 - 自定义模板和网址.就在我认为一切都很好的时候.我在NoReverseMatch
使用django-registration所需的自定义模板之一时遇到了错误{% url 'testing' item_id=123 %}
(我也尝试使用视图名称,myapp.views.test
而不是运气).有趣的是,我尝试reverse('testing', kwargs={'item_id':123})
在shell中,网址也很好.我认为在后端{% url %}
使用reverse()
但为什么我会得到不同的结果?
urls.py :(我网站的URLconf)
urlpatterns = patterns('myapp.views',
url(r'^test/(?P<item_id>\d+)/$', 'test', name='testing'),
)
Run Code Online (Sandbox Code Playgroud)
activation_email.txt :(所说的模板.请注意它是django-registration所要求的.txt扩展名中的故意,这不应该是问题的原因.)
{% comment %}Used to generate the body of the activation email.{% endcomment %}
Welcome to {{ site }}! Please activate your account by clicking on the following link:
{% url 'testing' item_id=123 %}
Note the activation link/code will be expired in {{ expiration_days }} days.
Run Code Online (Sandbox Code Playgroud)
我不知道它是否重要但只是想我应该提到activation_email.txt存储在模板目录中myapp
虽然它被使用django-registration
.
另外,我使用的是django 1.4
我有一种感觉,问题与url名称空间有关,这是一个我从未理解过的主题,但这只是一个天真的猜测.(IMO,django文档非常适合解释有关django的所有内容,除非涉及到url名称空间)
小智 12
我不是这里的专家,但是在我正在研究的Django项目中,我正在使用没有引号的url名称.我只是在我的一个模板中的类似行周围添加了引号,它产生了与错误相同的错误.
尝试:
{% url testing item_id=123 %}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2954 次 |
最近记录: |