Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#19661 closed Bug (invalid)

admin_urlname does not work as advertised

Reported by: david.reitter@… Owned by: nobody
Component: Uncategorized Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This fails to work in my template (1.5rc1):

{% url opts|admin_urlname: 'delete' a.pk %}

I get "Invalid filter: 'admin_urlname'. The syntax of 'url' changed in Django 1.5, see the docs.".

I've tried different variants of quoting to comply with the syntax, but no dice.

If there is no bug, I think the documentation needs to be updated at:

https://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-admin-urls

Change History (5)

comment:1 Changed 3 years ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Does your template include {% load admin_urls %} towards the top?

comment:2 Changed 3 years ago by anonymous

Thanks, good point. I added this, but now, this line:

<td><a href="{% url opts|admin_urlname:'add' %}/">{{e.symbol}}</a></td>

produces an error:

AttributeError at /exp/god/allassets
'str' object has no attribute 'app_label'

Exception Location: /Library/Python/2.7/site-packages/django/contrib/admin/templatetags/admin_urls.py in admin_urlname, line 9

comment:3 Changed 3 years ago by claudep

  • Resolution set to invalid
  • Status changed from new to closed

I guess that opts is not of the required type. Please use support channels before reporting a bug (TicketClosingReasons/UseSupportChannels). Reopen if you can show the bug is in Django.

comment:4 Changed 3 years ago by vdboor

Are you sure opts is a valid variable in your template?
It seems to me it got replaced by TEMPLATE_STRING_IF_INVALID

You can use the {% debug %} tag to print all content data,
or use {% print %} from django-debugtools to print the context data of your template in a formatted layout.

comment:5 Changed 3 years ago by david.reitter@…

Thanks for the pointers, and apologies for filing a spurious report.

Note: See TracTickets for help on using tickets.
Back to Top