I have a lot of models (say 30 or 40) which are so similar, that I have 
handled them using slightly modified class based views.

In urls.py:
urlpatterns = [
    path('list/<str:mName>/',            ItemListView.as_view()),
    path('create/<str:mName>/',          ItemCreateView.as_view()),
    path('update/<str:mName>/<pk>',      ItemUpdateView.as_view()),
    path('delete/<str:mName>/<pk>',      ItemDeleteView.as_view()),
]

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?
Or should I make a filter that will transform the model name and operation 
name to an url and accept that I have to code url logic outside urls.py
Or could I reprogram the path() function to make this possible?
Or should I violate DRY and simply write 4 path lines for each of my 40 
models?


cheers + thanks, Mikkel

-- 
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/9cc50a2b-b613-4427-a8e4-101f9bf394d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to