How to exclude certain parameters in dynamic urls?

EazyC

I am mapping a dynamic url parameter such as a pagename in my application like so myapp.com/[pagenamehere] My urls.py for this looks like:

url(r'^(?P<pagename>[a-zA-Z0-9_.-]*)/$', 
    views.all_pagenames, 
    name='all_pagenames')

However, the urls for myapp.com/login, myapp.com/register, myapp.com/about etc are already mapped in the urls.py file like so, for example:

url(r'^about/$', views.about, name='about')

How can I revise the dynamic url for pagenames so that words such as ‘login’ ‘about’ etc are excluded from possible pagename parameters and don’t forward to the “all_pagenames” function in the views and instead goes to the appropriate function?

bruno desthuilliers

Django will try each url pattern in definition order, so you don't have to worry about "exluding" your other urls, all you need is to make sure you define them before the catch-all "pagename" url pattern:

url(r'^about/$', views.about, name='about')
url(r'^login/$', views.login, name='login')
# etc
# and last:
url(r'^(?P<pagename>[a-zA-Z0-9_.-]*)/$', 
     views.all_pagenames, name='all_pagenames')

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to generate dynamic urls in flask?

Setting service worker to exclude certain urls only

How to exclude certain domains from an npm proxy

bootstrap how to exclude style on certain element

How to write a Mod Rewrite to exclude Shibboleth urls?

Convert Dynamic URLs with query parameters to static URLs

How to exclude certain vertices in gremlin titan

How to exclude (ignore) certain folders in vagrant rsync?

How to exclude certain columns of a pandas dataframe?

How to exclude certain terms for renaming in Android Studio

How to exclude certain values from elastic nest

How to exclude by xpath certain keyword and ID

How to exclude certain variables from recipe?

How to exclude parameters in Shiny bookmarking?

How to exclude an input if a certain value is entered

How to exclude certain possibilities from a regular expression?

How to exclude certain words in sentence. regex?

how to exclude certain columns being returned in hibernate

How do I exclude certain variable parts?

How to exclude a certain word in a regular expression in JMeter?

Sed help - how to exclude certain pattern

How to exclude certain variables from POJO for logging

how to exclude character if a certain character occurs earlier

How can I exclude certain salaries and then order by?

how to exclude unnecessary URLs in ZAP html report

How to exclude certain posts from showing up in wp_query if the post data does not fit parameters?

How to exclude certain string values via regex?

How to exclude loss computation on certain tensors in PyTorch?

How to exclude certain pages when using an htaccess module? How to exclude certain URLs?