| 1 | import django.views.static |
| 2 | from django.conf import settings |
| 3 | from django.contrib import admin |
| 4 | from django.http import HttpResponse |
| 5 | from django.urls import include, re_path |
| 6 | |
| 7 | import example.testapp.views |
| 8 | |
| 9 | admin.autodiscover() |
| 10 | |
| 11 | |
| 12 | def handle404(request, exception): |
| 13 | return HttpResponse("404") |
| 14 | |
| 15 | |
| 16 | def handle500(request): |
| 17 | return HttpResponse("500") |
| 18 | |
| 19 | |
| 20 | handler404 = "example.urls.handle404" |
| 21 | handler500 = "example.urls.handle500" |
| 22 | |
| 23 | |
| 24 | if django.VERSION < (1, 9): |
| 25 | urlpatterns = [re_path(r"^admin/", include(admin.site.urls), name="admin")] |
| 26 | else: |
| 27 | urlpatterns = [re_path(r"^admin/", admin.site.urls, name="admin")] |
| 28 | |
| 29 | urlpatterns += [ |
| 30 | re_path( |
| 31 | r"^media/(.*)$", |
| 32 | django.views.static.serve, |
| 33 | {"document_root": settings.MEDIA_ROOT}, |
| 34 | ), |
| 35 | re_path( |
| 36 | r"^parkingarea/(?P<pk>\d+)/$", |
| 37 | example.testapp.views.parkingarea_update, |
| 38 | name="parkingarea", |
| 39 | ), |
| 40 | re_path(r"^", include("django.contrib.staticfiles.urls")), |
| 41 | ] |