Update urls & add custom error pages

This commit is contained in:
Nyymix 2025-03-22 00:46:17 +02:00
parent ce5031b64f
commit 0787465224
5 changed files with 58 additions and 10 deletions

View file

@ -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'

View file

@ -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)