I'm using Django 1.4 and am getting the following error
Reverse for 'dj' with arguments '()' and keyword arguments '{'dj_name': u"John O'Callaghan"}' not found.
Using John OCallaghan
instead of John O'Callaghan
in the database works perfectly fine and doesn't give an error.
Here is the line that gives the error
<a href="{% url 'dj' dj_name=dj.name %}"><img src="{{ MEDIA_URL }}{{ dj.img }}" class="img-rounded" id="dj_img"/></a>
I read at quite a few places that you are not supposed to use quotes in {% url %}
in Django 1.4. Using {% url dj dj_name=dj.name %}
instead of {% url 'dj' dj_name=dj.name %}
gives the following error instead
TypeError - cannot concatenate 'str' and 'DJ' objects
urls.py
urlpatterns = patterns('hunt.views',
url(r'^$', views.landing, name='landing'),
url(r'^top100/$', views.top100, name='top100'),
url(r'^top100/(?P<dj_name>[a-zA-Z0-9 &-]+)/$', views.dj, name='dj'),
)
Having seen your URL, I'm surprised at your surprise that it is not working with "O'Callaghan". Your regex specifies exactly the characters that it accepts: a to z, A to Z, 0 to 9, space, ampersand, and hyphen. Apostrophe is not there. If you want it to accept an apostrophe, you need to add it to that list.