[Django] #35616: "url" template tag works with a context variable only if left unquoted

2024-07-18 Thread Django
#35616: "url" template tag works with a context variable only if left unquoted
---+---
 Reporter:  Pzdrs  | Type:  Uncategorized
   Status:  new|Component:  Template system
  Version:  5.0| Severity:  Normal
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+---
 I tried passing a context variable as the url_name parameter like so:

 {{{
 {% url 'url' %}
 }}}

 Django raises a NoReverseMatch exception - Reverse for 'url' not found.
 'url' is not a valid view function or pattern name.

 When left unquoted like so:

 {{{
 {% url url %}
 }}}

 PyCharm gives me a warning (View names should be in quotes since Django
 1.5 and should have no quotes before 1.5) despite Django apparently
 accepting this and resolving to the correct URI.

 Using Django 5.0.7
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190c783775a-e1fafb3c-b5ff-43c9-a3fa-14e2b6ada684-00%40eu-central-1.amazonses.com.


Re: [Django] #35616: "url" template tag works with a context variable only if left unquoted

2024-07-19 Thread Django
#35616: "url" template tag works with a context variable only if left unquoted
-+--
 Reporter:  Petr Boháč   |Owner:  (none)
 Type:  Uncategorized|   Status:  closed
Component:  Template system  |  Version:  5.0
 Severity:  Normal   |   Resolution:  invalid
 Keywords:   | Triage Stage:  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+--
Changes (by Sarah Boyce):

 * resolution:   => invalid
 * status:  new => closed

Comment:

 Hi Petr, in the
 [https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#url
 documentation for url], there is a warning:

 > Don’t forget to put quotes around the URL pattern name, otherwise the
 value will be interpreted as a context variable!

 In this case, you want it to be treated as a context variable and so not
 adding quotes is correct and adding them treats it as a view name.
 This is working as expected to me and the behaviour is documented. Please
 feel free to give feedback to PyCharm 👍
-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070190c9ee5fbb-91ee709f-0b06-48d3-a620-f8f65f1b7ded-00%40eu-central-1.amazonses.com.