Saturday, April 23, 2016

Re: [django1.9] Url template tag, dotted path and decorator

On Saturday, April 23, 2016 at 1:17:26 PM UTC-4:30, François Magimel wrote:
Hi!

I'm facing an issue reversing a dotted path with django 1.9.4. Here are more details.

I pass a dotted path to the django template tag "url":
    "{% url 'my.app.view.func' arg %}"
And the function "my.app.view.func" has a decorator which is using "arg". My problem is : when displaying my template, I get a NoReverseMatch error.
But I don't have any error:
  - when I use the name of the url (defined in my urls.py file) or
  - when I use the dotted path and remove my (simple) decorator.

I know that passing a dotted path to url is deprecated since django 1.8 [0][1], but not removed yet. So, I think there is something wrong with dotted path and decorators, but I can't find what…

PS: my decorator only redirects to another view…

Thanks,
François


[0] https://docs.djangoproject.com/en/1.8/releases/1.8/#passing-a-dotted-path-to-reverse-and-url
[1] https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#url

Hi,
May be you can use functools.wraps from Python standard library.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/31e70c60-a119-4bba-a903-6af4affd5bbe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment