I read lot's of docs, tried everything and still can't understand why my template returns Reverse for '' with arguments '(1,)' and keyword arguments '{}' not found error. Please see error dump here: http://dpaste.com/721187/
The tag I use in change_form.html template is {% url pdfview 1 %}
The class FVatAdmin(admin.ModelAdmin) has get_urls method which looks like this:
def get_urls(self):
urls = super(FVatAdmin, self).get_urls()
my_urls = patterns('',
url(r'^view/(?P<id>\d+)', self.admin_site.admin_view(self.pdf_view), name="pdfview"),
url(r'^js/calculate', self.admin_site.admin_view(self.calculate), name="calc"),
)
return my_urls + urls
The url and pdfview defined above work just fine, but somewhat don't resolve via {% url pdfview 1 %} in a template and via reverse('pdfview', args={1}) in a view or via shell.
I just can't understand what I'm doing wrong. I'm a newbie in Django... H E L P :)
Django admin urls are namespaced in order not to clash with other urls.
Try doing the following {% url admin:pdfview 1 %}
See this for details:
https://docs.djangoproject.com/en/1.4/topics/http/urls/#topics-http-reversing-url-namespaces
Put url name in quotes.
{% url "admin:pdfview" 1 %}
UPDATE: this applies only for Django 1.3/1.4 if:
{% load url from future %}
is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With