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 = [ 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", ), path( "-/", views.YearView.as_view(), name="year_view", ), path("latest/", views.latestPublication, name="latestPublication"), ]