Update urls & add custom error pages
This commit is contained in:
parent
ce5031b64f
commit
0787465224
5 changed files with 58 additions and 10 deletions
|
@ -1,4 +1,3 @@
|
|||
from django.shortcuts import redirect
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
@ -15,8 +14,3 @@ urlpatterns = [
|
|||
path('albums/', views.AlbumsList.as_view(), name='albums_url'),
|
||||
path('<path:redir_path>/', views.redirect_to_album, name='redirect_to_album'),
|
||||
]
|
||||
|
||||
def custom_404_view(request, exception):
|
||||
return redirect('/')
|
||||
|
||||
handler404 = 'gallery.urls.custom_404_view'
|
|
@ -1,5 +1,3 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
|
@ -93,7 +91,7 @@ class About(TemplateView):
|
|||
template_name = "gallery/about.html"
|
||||
|
||||
|
||||
|
||||
def redirect_to_album(request, redir_path):
|
||||
redir = get_object_or_404(Redir, path=redir_path)
|
||||
return redirect('gallery:album_url', album_slug=redir.album.slug)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue