jeudi 5 octobre 2017

possible to group urlpatterns of the same app?django

I know that in each app, we can use our own urlpatterns and include it in the main project / app using include.

I am wondering if an app have a few different urls, is there a way to group it?

for example

urlpatterns = [
    url(r'^user/$', hello.asView(), 
    url(r'^user/hello/$', hello.asView(), 
    url(r'^user/there/$', hello.asView(), 
    url(r'^user/here/$', hello.asView(), 
    url(r'^user/that/$', hello.asView(), 
    url(r'^user/mini/$', hello.asView(), 
    url(r'^user/max/$', hello.asView(), 

    url(r'^bb/$', hello.asView(), 
    url(r'^bb/hello/$', hello.asView(), 
    url(r'^bb/there/$', hello.asView(), 
    url(r'^bb/here/$', hello.asView(), 
    url(r'^bb/that/$', hello.asView(), 
    url(r'^bb/mini/$', hello.asView(), 
    url(r'^bb/max/$', hello.asView(), 
]

please ignore all the hello.asView() but I am wondering if there's a way to group all the user and bb so if there are more url, I don't need to keep on typing user or bb again?

thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire