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
On 19/07/11 11:08, NISA BALAKRISHNAN wrote:
how to add url names to the following entry in urls.py.
( r'^all/synchro/download/file/', "get_all_data_download" )
Use the url function [1]
url( r'^all/synchro/download/file/', "get_all_data_download",
n
how to add url names to the following entry in urls.py.
( r'^all/synchro/download/file/', "get_all_data_download" )
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to dja
On Saturday, January 15, 2011 11:23:02 am Vitaly Babiy wrote:
> The url docs talks about naming urls like this: myapp-comment, does it make
> sense to do this still when we have namespaces? With a namespace we could
> do myapp:comment this way the url name only describes the view and has no
> refer
The url docs talks about naming urls like this: myapp-comment, does it make
sense to do this still when we have namespaces? With a namespace we could do
myapp:comment this way the url name only describes the view and has
no reference to the application name that its in.
--
You received this me
Hello there!
I'm seeking some design advice, and I hope you'll have some
suggestions :)
I'm storing my site's menu structure into the database so that I can
edit it from the admin. Here's the code:
class MenuItem(models.Model):
caption = models.CharField(max_length=30)
url = models.Char
10 matches
Mail list logo