Well, ... I know about reverse_lazy

Sorry for not explaining myself good enough:

reverse_lazy can't do:

url( 'bar/foo/(?P<pk>[0-9]*)/', *RedirectView*( url= 
*reverse_lazy*('foo_stuff') 
),

url( 'foo/(?P<pk>[0-9]*)/', some_view_func, name = 'foo_stuff' ), 


What a RedirectView supporting URL Names (...) could do: 

url( 'bar/foo/(?P<pk>[0-9]*)/', *RedirectView*( view_name = 'foo_stuff' ),

url( 'foo/(?P<pk>[0-9]*)/', some_view_func, name = 'foo_stuff' ), 


I'm handling it as a view-name instead of url name, because in my opinion, 
a view in -some specific URL-Context- always has a name that can be chosen, 
that even if the URL changes in some detail, it would remain the same:
* posts_by_specific_user * or something like that - if it is located in 
'/user/<user-pk>/posts/' or 
'/department/<who-cares-we-have-the-global-user-pk>/users/<user-pk>/posts/' 
An URL... well i wouldn't know why to name a URL - a URL is more or less 
something like a name / identifier. Just not this intuitive understandable 
or in some cases  longtime-persistent. Changing a URL would somehow result 
in changing the url-name (because otherwise the name would result form 
something else than the URL itself) - and thats just a real pity because 
something that does the same would be named differently.

Benefit for using it like this: 

   - Caused by whatever decisions (this shouldn't happen but most likely 
   always will..) the url of a specific VIEW changes, one can now support the 
   legacy URL because other sites might have linked to it and 301 (Moved 
   Permanently) Redirect it to the new URL, specified by the view name.
   - Or in some other case for APIs when representing a Resource: when 
   having the same resource at two different URLs, one can easily 302 redirect 
   it to one *base* view (once again, the URL might change. especially when 
   using versioned URLs)

 
What would needed to be changed in *RedirectView*:

By having something like this in the *get()* method:

*get_redirect_url(request, args=args kwargs=kwargs)*

 
and in *get_redirect_url:*

*elif self.view_name:*

*url = reverse( self.view_name, args=args, kwargs=kwargs)*

one could dynamically pass those url args and kwargs, of a dynamic url


regarding to https://code.djangoproject.com/ticket/15273: 
i don't understand why such a basic concept like named urls/views are 
somehow integrated in django (template tag: url) but in this case just 
accessible 
through nasty workarounds (reverse_lazy). In my opinion a workaround like 
this often just points out, that something is probably unfinished. And in 
my opinion this is definitely the case when looking at RedirectView and 
those .. view-names .. because some important functionality is not 
available.

So - i would really appreciate having this functionality (as far as i don't 
miss anything you guys thought about, that speaks against it).


best regards
ludwig

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/39XYBkpXwncJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to