Take the 2-minute tour ×

Lets take the standard example

class Author(models.Model):
  name = models.CharField(max_length=100)

class Book(models.Model):
  title = models.CharField(max_length=100)
  author = models.ForeignKey(Author)
  #... Many other fields ...

From the admin change template of Author trying to access to the related books

  {% for book in original.book_set.all %}
      <a href="{% url admin:myapp_manager_change book.id %}">Edit {{ book }}</a>
  {% endfor %}

I get

Caught NoReverseMatch while rendering: Reverse for 'myapp_manager_change' with arguments '(1L,)' and keyword arguments '{}' not found.

Why ?
And how can I access this book_set ?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Check the docs on reversing admin urls.

You have to replace "myapp" with your actual app:

admin:{{ app_label }}_{{ model_name }}_change object_id

So if your app is named library and your model's name is book the link would be:

<a href="{% url admin:library_book_change book.id %}">Edit {{ book }}</a>
share|improve this answer
Thank you, it's so obvious, I was trying to use the URL reversing system without knowing. –  Pierre de LESPINAY Nov 8 '11 at 14:59
Glad i could help :-) –  arie Nov 8 '11 at 15:02
add comment

book_set actually works well in your example because the exception is raised from inside the for loop. It seems the problem is with the view name.

Try this:

{% url admin:myapp_book_change book.id %}
share|improve this answer
Thank you I changed myapp to my_actual_app and manager to my_actual_model :) –  Pierre de LESPINAY Nov 8 '11 at 14:57
add comment

Your Answer


