Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-25 Thread Mikkel Kromann
Thank you so much for your help, Melvyn. With your help I managed to the the code running :) Here it is, if somebody should find it helpful. cheers, Mikkel >From somewhere, e.g. models.py # The list of model names (just add your model names to it) def GetItemNames(): return [ 'Year', 'Vintage

Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-23 Thread Melvyn Sopacua
On zaterdag 23 juni 2018 14:30:08 CEST Mikkel Kromann wrote: > In models.py: > def GetItemPaths():paths = [ ] > for i in [ 'Model1', 'Model2', 'Model3' ]: > p = path( i + '/list/', ItemListView.as_view(model=i), name=i + > '_list' ) > paths.append(p) > > return paths >

Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-23 Thread Mikkel Kromann
So, I think I have a neat idea for solving my problem, simply make a function which returns a list of path() returns. In urls.py urlpatterns = GetItemPaths() + [ # other paths ] In models.py: def GetItemPaths():paths = [ ] for i in [ 'Model1', 'Model2', 'Model3' ]: p = path( i +

Re: Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-21 Thread Melvyn Sopacua
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//',ItemListView.as_view(), name= > mName+'_list'), > ] > > From what I

Is it possible to construct reversible url names in urls.py using , regex etc

2018-06-21 Thread Mikkel Kromann
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//',ItemListView.as_view()), path('create//', ItemCreateView.as_view()), path('update//', Ite