title: Django NoReverseMatch in reverse() call
body: <p>I've been spending another night on this... Can someone help?</p>
  
  <p>I am trying to replicate the kickstart example at <a href="http://lightbird.net/dbe/todo_list.html" rel="nofollow">http://lightbird.net/dbe/todo_list.html</a> which seems to have been developed for earlier versions of Django (and is not describing comprehensively the how-to's)</p>
  
  <p>Anyhow, I manage the tasks until "Marking task as Done". And then my issues start.</p>
  
  <p>To be clear, all is fine until I add the "mark_done" to the list_display attribute in my ItemAdmin class. Then it seems not to be able to resolve truc.todo.views.mark_done
  I have tried full, absolute module reference, and the partial one you see below, to no avail.
  I would prefer the partial one (starting by "todo") as it means easy portability to other projects.</p>
  
  <p>Thanks ahead for your help.</p>
  
  <p>I have a file tree as follows:</p>
  
  <pre><code>truc/ (my project)
  |-todo/ (my app)
  | |-__init__.py
  | |-views.py
  | |-urls.py  (module urls)
  | |-models.py
  | |-templates/admin/todo/item/change_list.html
  |-truc/
  | |-urls.py  (main urls)
  | |-settings.py
  | |-etc.
  </code></pre>
  
  <h1>My main urls contains:</h1>
  
  <pre><code>from django.conf.urls import patterns, include, url
  from django.contrib import admin
  admin.autodiscover()
  
  urlpatterns = patterns('',
      url(r'^todo/$', include('todo.urls')),
      url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
      url(r'^admin/', include(admin.site.urls)),
  )
  </code></pre>
  
  <h1>My module urls contains:</h1>
  
  <pre><code>from django.conf.urls import patterns, include, url
  
  urlpatterns = patterns('todo.views',
      url(r'^mark_done/(\d*)/$', 'mark_done'),
  )
  </code></pre>
  
  <h1>In models.py I have:</h1>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from django.contrib import admin
  
  from django.utils.translation import ugettext as _
  from django.utils.encoding import force_text
  from django.http import Http404, HttpResponse, HttpResponseRedirect
  from django.core.urlresolvers import reverse
  
  [...]
  class Item(models.Model):
      name = models.CharField(max_length=60)
      created = models.ForeignKey(DateTime)
      priority = models.IntegerField(default=0)
      difficulty = models.IntegerField(default=0)
      done = models.BooleanField(default=False)
  
      def mark_done(self):
  ### The below is THE line which I cannot have work...
          return "&lt;a href='%s'&gt;Done&lt;/a&gt;" % reverse("todo.views.mark_done", args=[self.pk])
      mark_done.allow_tags = True
  
  class ItemAdmin(admin.ModelAdmin):
      list_display = ["name", "priority", "difficulty", "created", "mark_done", "done"]
      search_fields = ["name"]
  [...]
  </code></pre>
  
  <h1>Error and traceback:</h1>
  
  <pre><code>NoReverseMatch at /admin/todo/item/
  Reverse for 'todo.views.mark_done' with arguments '(5,)' and keyword arguments '{}' not found.
  Request Method: GET
  Request URL:    http://127.0.0.1:8000/admin/todo/item/
  Django Version: 1.5
  Exception Type: NoReverseMatch
  Exception Value:    
  Reverse for 'todo.views.mark_done' with arguments '(5,)' and keyword arguments '{}' not found.
  Exception Location: /Library/Python/2.7/site-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 416
  Python Executable:  /usr/bin/python
  Python Version: 2.7.1
  
  [...]
  Template error:
  In template /Users/arnaud/Documents/truc/todo/templates/admin/todo/item/change_list.html, error at line 92
     Reverse for 'todo.views.mark_done' with arguments '(5,)' and keyword arguments '{}' not found.
     82 :         {% endif %}
  
  
     83 :       {% endblock %}
  
  
     84 : 
  
  
     85 :       &lt;form id="changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %}&gt;{% csrf_token %}
  
  
     86 :       {% if cl.formset %}
  
  
     87 :         &lt;div&gt;{{ cl.formset.management_form }}&lt;/div&gt;
  
  
     88 :       {% endif %}
  
  
     89 : 
  
  
     90 :       {% block result_list %}
  
  
     91 :           {% if action_form and actions_on_top and cl.full_result_count %}{% admin_actions %}{% endif %}
  
  
     92 :            {% result_list cl %} 
  
  
     93 :           {% if action_form and actions_on_bottom and cl.full_result_count %}{% admin_actions %}{% endif %}
  
  
     94 :       {% endblock %}
  
  
     95 :       {% block pagination %}{% pagination cl %}{% endblock %}
  
  
     96 :       &lt;/form&gt;
  
  
     97 :     &lt;/div&gt;
  
  
     98 :   &lt;/div&gt;
  
  
     99 : {% endblock %}
  
  
     100 : 
  
  Traceback:
  File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
    140.                     response = response.render()
  File "/Library/Python/2.7/site-packages/django/template/response.py" in render
    105.             self.content = self.rendered_content
  File "/Library/Python/2.7/site-packages/django/template/response.py" in rendered_content
    82.         content = template.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    140.             return self._render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
    134.         return self.nodelist.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
    124.         return compiled_parent._render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
    134.         return self.nodelist.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
    124.         return compiled_parent._render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in _render
    134.         return self.nodelist.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
    63.             result = block.nodelist.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File "/Library/Python/2.7/site-packages/django/template/loader_tags.py" in render
    63.             result = block.nodelist.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    830.                 bit = self.render_node(node, context)
  File "/Library/Python/2.7/site-packages/django/template/debug.py" in render_node
    74.             return node.render(context)
  File "/Library/Python/2.7/site-packages/django/template/base.py" in render
    1185.                     _dict = func(*resolved_args, **resolved_kwargs)
  File "/Library/Python/2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in result_list
    286.             'results': list(results(cl))}
  File "/Library/Python/2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in results
    264.             yield ResultList(None, items_for_result(cl, res, None))
  File "/Library/Python/2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in __init__
    256.         super(ResultList, self).__init__(*items)
  File "/Library/Python/2.7/site-packages/django/contrib/admin/templatetags/admin_list.py" in items_for_result
    184.             f, attr, value = lookup_field(field_name, result, cl.model_admin)
  File "/Library/Python/2.7/site-packages/django/contrib/admin/util.py" in lookup_field
    258.                 value = attr()
  File "/Users/arnaud/Documents/truc/todo/models.py" in mark_done
    76.         return "&lt;a href='%s'&gt;Done&lt;/a&gt;" % reverse("todo.views.mark_done", args=[self.pk])
  File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in reverse
    496.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
    416.                 "arguments '%s' not found." % (lookup_view_s, args, kwargs))
  
  Exception Type: NoReverseMatch at /admin/todo/item/
  Exception Value: Reverse for 'todo.views.mark_done' with arguments '(5,)' and keyword arguments '{}' not found.
  </code></pre>
  
  <h2>Local vars as in the _reverse_with_prefix of urlresolvers.py:</h2>
  
  <pre><code>candidate   u'/todo/mark_done/5/'
  val 5
  pattern 'todo/$mark_done/(\\d*)/$'
  self    &lt;RegexURLResolver 'truc.urls' (None:None) ^/&gt;
  args    (5,)
  _prefix u'/'
  m   'todo.views'
  possibility [(u'todo/mark_done/%(_0)s/', [u'_0'])]
  lookup_view_s   u'todo.views.mark_done'
  possibilities   [([(u'todo/mark_done/%(_0)s/', [u'_0'])], 'todo/$mark_done/(\\d*)/$', {})]
  lookup_view &lt;function mark_done at 0x10da242a8&gt;
  prefix_norm u'/'
  prefix_args []
  params  [u'_0']
  result  u'todo/mark_done/%(_0)s/'
  defaults    {}
  kwargs  {}
  n   'mark_done'
  unicode_args    [u'5']
  </code></pre>