fix(urls): Use modern syntax
This commit is contained in:
parent
eab76e9d0c
commit
0c35609496
1 changed files with 22 additions and 9 deletions
|
@ -1,20 +1,33 @@
|
|||
from django.conf.urls import url
|
||||
from django.urls import path, register_converter
|
||||
|
||||
from . import views
|
||||
|
||||
|
||||
class FourDigitYearConverter:
|
||||
regex = "[0-9]{4}"
|
||||
|
||||
def to_python(self, value):
|
||||
return int(value)
|
||||
|
||||
def to_url(self, value):
|
||||
return "%04d" % value
|
||||
|
||||
|
||||
register_converter(FourDigitYearConverter, "yyyy")
|
||||
|
||||
urlpatterns = [
|
||||
url(r"^$", views.HomeView.as_view(), name="homepage"),
|
||||
url(r"^robots.txt$", views.robots_view, name="robots"),
|
||||
url(r"^ecrire$", views.WriteArticleView.as_view(), name="write_article"),
|
||||
url(
|
||||
r"^speciaux/",
|
||||
path("", views.HomeView.as_view(), name="homepage"),
|
||||
path("robots.txt", views.robots_view, name="robots"),
|
||||
path("ecrire/", views.WriteArticleView.as_view(), name="write_article"),
|
||||
path(
|
||||
"speciaux/",
|
||||
views.SpecialPublicationsView.as_view(),
|
||||
name="special_publications",
|
||||
),
|
||||
url(
|
||||
r"^(?P<year>\d{4})-(?P<nYear>\d{4})/",
|
||||
path(
|
||||
"<yyyy:year>-<yyyy:nYear>/",
|
||||
views.YearView.as_view(),
|
||||
name="year_view",
|
||||
),
|
||||
url(r"^latest$", views.latestPublication, name="latestPublication"),
|
||||
path("latest/", views.latestPublication, name="latestPublication"),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue