1

I am trying to redirect my view to a url with get request parameter but is error.

Reverse for 'article-detail-view' with arguments '(u'Django is a powerful web framework that can help you get your Python application or website off the ',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['article/(?P<slug>\\w+).html$']

Error during template rendering

{% for article in hot_article_list %}
<li class="list-group-item">
   <span class="hotest-post-title"><a href="
      {% url 'article-detail-view' article.en_title %}
      ">{{article.title}}</a> </span>
   <span class="badge">{{article.view_times}}</span>
</li>
{% endfor %}

Url Pattern:

url(r'^$', IndexView.as_view(), name='index-view'),
url(r'^article/(?P<slug>\w+).html$',
    ArticleView.as_view(), name='article-detail-view')

Please help me, thanks!

Anounys
  • 11
  • 3
  • The argument should be `article.slug`, not `article.en_title`: `{% url 'article-detail-view' article.slug %}` – solarissmoke Aug 07 '16 at 02:24
  • I edit but error: Reverse for 'article-detail-view' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['article/(?P\\w+).html$'] – Anounys Aug 07 '16 at 02:30
  • Does your `article` model actually have a `slug` field? If not, you cannot use `slug` in the URL configuration for that view. – solarissmoke Aug 07 '16 at 02:36
  • Article model: http://pastebin.com/rHzh9xm3 – Anounys Aug 07 '16 at 02:45
  • Your model does not have a field called `slug`, but you are trying to use such a field in the URL for that model. Suggest you read through the documentation on [how to create URLs](https://docs.djangoproject.com/en/1.10/topics/http/urls/) to understand how to define them. – solarissmoke Aug 07 '16 at 02:49
  • 1
    Possible duplicate of [What is a NoReverseMatch error, and how do I fix it?](http://stackoverflow.com/questions/38390177/what-is-a-noreversematch-error-and-how-do-i-fix-it) – solarissmoke Aug 07 '16 at 02:51
  • Thanks you very much. – Anounys Aug 07 '16 at 03:29

0 Answers0