from django.conf.urls import url from django.views.generic.base import RedirectView from . import views urlpatterns = [ url( regex=r'(?P[\w]+)/(?P\d+)/', view=views.BirdListUserView.as_view(), name='list_by_person' ), url( regex=r'(?P\d+)/$', view=views.BirdListView.as_view(), name="list" ), url( regex=r'^(?P[-_\w]+)$', view=views.BirdDetailView.as_view(), name='detail' ), # redirect /slug/ to /slug/1/ for live server url( regex=r'(?P[-\w]+)/$', view=RedirectView.as_view(url="/birds/%(user)s/1/", permanent=False), name="list_person_redirect" ), url( regex=r'', view=RedirectView.as_view(url="/birds/1/", permanent=False), name="list_redirect" ), ]