On donderdag 21 juni 2018 10:19:08 CEST Mikkel Kromann wrote:

> However, I'd really like to give all my urls names so that they can be
> easily reversed (e.g. success links).
> urlpatterns = [
>     path('list/<str:mName>/',            ItemListView.as_view(),      name=
> mName+'_list'),
> ]
> 
> From what I can see, my model name mName is passed only to the view and
> apparently not to the name constructor inside urls.py
> Also, while I do not entirely understand the reverse naming process, I
> sense that it might not be too easy to reverse the url name if it is not
> spelled out directly.
> 
> Are there any options for handling this in urls.py?

Take a look at crudlfap's Router class to see how to generate dynamic urls. In 
short: let a router who generates views for models generate the urlpatterns. 
All django is looking for is an iterable that is named 'urlpatterns' in a urls 
module.

https://github.com/yourlabs/crudlfap/blob/master/src/crudlfap/router.py#L274
-- 
Melvyn Sopacua

-- 
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+unsubscr...@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/7023284.eSgYguR0o7%40fritzbook.
For more options, visit https://groups.google.com/d/optout.

Reply via email to