Coverage for charity\urls.py: 67%

9 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-06-20 12:38 +0100

1""" 

2URL configuration for charity project. 

3 

4The `urlpatterns` list routes URLs to views. For more information please see: 

5 https://docs.djangoproject.com/en/5.0/topics/http/urls/ 

6Examples: 

7Function views 

8 1. Add an import: from my_app import views 

9 2. Add a URL to urlpatterns: path('', views.home, name='home') 

10Class-based views 

11 1. Add an import: from other_app.views import Home 

12 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 

13Including another URLconf 

14 1. Import the include() function: from django.urls import include, path 

15 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 

16""" 

17from django.contrib import admin 

18from django.urls import path, include 

19from django.views.defaults import page_not_found as default_page_not_found 

20 

21from donation.views import donations 

22 

23urlpatterns = [ 

24 path('admin/', admin.site.urls), 

25 path('', donations, name='donations'), 

26 path('', include('donation.urls')), 

27 path('donat/', include('donate.urls')), 

28 path('accounts/', include('allauth.urls')), 

29] 

30 

31 

32def custom_page_not_found(request, exception): 

33 """ 

34 Custom handler for page not found (404) errors. 

35 

36 Args: 

37 request (HttpRequest): The HTTP request object. 

38 exception (Exception): The exception that triggered the 404 error. 

39 

40 Returns: 

41 HttpResponse: The response with the custom 404 page. 

42 """ 

43 response = default_page_not_found(request, exception) 

44 response.template_name = '404.html' 

45 return response