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
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
>
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 +
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
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
5 matches
Mail list logo