0

I can't figure out why this one scenario of using {% url %} with parameters in this template is tripping me up. I've done it before and it worked fine but I can't find what's wrong with this code.

urls.py

url(r'^promotions/$', views.promotions, name="promotions"),
url(r'^promotions/(?P<title>[-\w]+)/$', views.promotion_detail, name="promotions_detail"),

promotion.html

    {% for promotion in promotions %}
    <div class="a-promotion">
        <div class="column-1">
            <div class="title">{{promotion.title}}</div>
            <div class="offer">{{promotion.amount}}</div>
        </div>
        <div class="column-2">
            **********THE LINE BELOW THROWS THE ERROR******************
            {{promotion.short_description}}... <a href="{% url 'promotions_detail' title=promotion.title %}"><span class="learn-more">Learn More</span></a>
        </div>
    </div>
    {% endfor %}

Error: NoReverseMatch at /promotions/

Reverse for 'promotions_detail' with arguments '()' and keyword arguments '{u'title': u'Welcome to Our Site'}' not found. 1 pattern(s) tried: ['promotions/(?P<title>[-\\w]+)/$']
qarthandso
  • 2,100
  • 2
  • 24
  • 40
  • 7
    your url doesn't accept spaces, nor should it - you should use a slug – Sayse Dec 06 '16 at 15:14
  • 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) – Sayse Dec 06 '16 at 15:16

0 Answers0