Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

django slug int url mapping

# in views define the int slugs then the url mapping is like this

from django.urls import path, re_path

from . import views

urlpatterns = [
    path('articles/2003/', views.special_case_2003),
    re_path(r'^articles/(?P<year>[0-9]{4})/$', views.year_archive),
    re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$', views.month_archive),
    re_path(r'^articles/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>[w-]+)/$', views.article_detail),
]
Comment

PREVIOUS NEXT
Code Example
Python :: swap variables in python 
Python :: pandas dataframe compare two dataframes and extract difference 
Python :: python sort dictionary by value 
Python :: can is slice list with list of indices python 
Python :: python arguments 
Python :: pyqt5 qtreewidgetitem enable drop drag 
Python :: sort first element reverse sort second python 
Python :: django q objects 
Python :: MAKE A SPHERE IN PYTHON 
Python :: how to remove none in python 
Python :: set allowed methods flask 
Python :: huggingface transformers change download path 
Python :: flask wtforms multiple select 
Python :: python array colon 
Python :: filter in pandas 
Python :: seaborn pink green color palette python 
Python :: dataframe to ftp 
Python :: assign a same value to 2 variables at once python 
Python :: time date year python 
Python :: python os get path 
Python :: insert data in django models 
Python :: pil.jpegimageplugin.jpegimagefile to image 
Python :: django apiview pagination 
Python :: do not show figure matplotlib 
Python :: function for detecting outliers in python 
Python :: linear search python 
Python :: input in python 
Python :: drop-trailing-zeros-from-decimal python 
Python :: python array slice 
Python :: python user input to tuple 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =