Changeset View
Changeset View
Standalone View
Standalone View
films/urls.py
| from django.contrib.flatpages import views | |||||
| from django.urls import path | from django.urls import path | ||||
| from films.views import films, gallery, production_logs | from films.views import films, gallery, production_logs | ||||
| from films.views.api.assets import asset as api_asset, asset_zoom, comment | from films.views.api.assets import asset as api_asset, asset_zoom, comment | ||||
| from films.views.api.production_logs import production_logs_page | from films.views.api.production_logs import production_logs_page | ||||
| urlpatterns = [ | urlpatterns = [ | ||||
| path('api/assets/<int:asset_pk>', api_asset, name='api-asset'), | path('api/assets/<int:asset_pk>', api_asset, name='api-asset'), | ||||
| path('api/assets/<int:asset_pk>/zoom', asset_zoom, name='api-asset-zoom'), | path('api/assets/<int:asset_pk>/zoom', asset_zoom, name='api-asset-zoom'), | ||||
| path('api/assets/<int:asset_pk>/comment', comment, name='api-asset-comment'), | path('api/assets/<int:asset_pk>/comment', comment, name='api-asset-comment'), | ||||
| path('api/films/<int:film_pk>/logs', production_logs_page, name='api-logs-page'), | path('api/films/<int:film_pk>/logs', production_logs_page, name='api-logs-page'), | ||||
| path('', films.film_list, name='film-list'), | path('', films.film_list, name='film-list'), | ||||
| path('<slug:film_slug>', films.film_detail, name='film-detail'), | path('<slug:film_slug>', films.film_detail, name='film-detail'), | ||||
| path('<slug:film_slug>/about', films.about, name='film-about'), | |||||
| path('<slug:film_slug>/gallery', gallery.collection_list, name='film-gallery'), | path('<slug:film_slug>/gallery', gallery.collection_list, name='film-gallery'), | ||||
| path( | path( | ||||
| '<slug:film_slug>/production-logs', | '<slug:film_slug>/production-logs', | ||||
| production_logs.production_log_list, | production_logs.production_log_list, | ||||
| name='film-production-logs', | name='film-production-logs', | ||||
| ), | ), | ||||
| path('<slug:film_slug>/assets/<slug:asset_slug>', gallery.asset_detail, name='asset-detail'), | path('<slug:film_slug>/assets/<slug:asset_slug>', gallery.asset_detail, name='asset-detail'), | ||||
| path( | path( | ||||
| '<slug:film_slug>/<slug:collection_slug>', | '<slug:film_slug>/<slug:collection_slug>', | ||||
| gallery.collection_detail, | gallery.collection_detail, | ||||
| name='collection-detail', | name='collection-detail', | ||||
| ), | ), | ||||
| ] | ] | ||||
| def flatpage(request, film_slug, url): | |||||
sybren: Here page URLs end with a slash, whereas in the other URL patterns this is not the case. If the… | |||||
| return views.flatpage(request, film_slug + '/' + url) | |||||
sybrenUnsubmitted Done Inline ActionsA view function in the urls.py file? I would just put it in the views code, where it belongs. sybren: A view function in the `urls.py` file? I would just put it in the views code, where it belongs. | |||||
| urlpatterns += [ | |||||
| path('<slug:film_slug>/about/', flatpage, {'url': 'about/'}, name='film-about'), | |||||
| ] | |||||
Here page URLs end with a slash, whereas in the other URL patterns this is not the case. If the trailing slash is really necessary, at least document why this is the case. If it is not really necessary, the view code can also be simplified.