-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Description
In the latest Django stable one can't use patterns() anymore:
RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
This was quite nice as one didn't have to pass default actions to views with default actions. When doing the following today:
urlpatterns = [
url(r"things", views.ThingView.as_view()),
]
We get a warning from the .as_view() override due to the way that #2171 was solved with #2175:
TypeError: The
actions
argument must be provided when calling.as_view()
on a ViewSet. For example.as_view({'get': 'list'})
The problematic part is when ThingView uses e.g. ModelViewSet or another viewset with default actions defined. It would be nice if the patch for #2171 would take the type of view in consideration and if actions is None default to the actions that exist in the viewset by default. It currently appears that we need to solve the problem this way, passing actions dictionaries for a viewset with default actions set because actions is not permitted to be None and does not default to the default values of the view:
urlpatterns = [
url(r"things/$", views.ThingView.as_view({"get": "list"}), name="ticket-list"),
url(r"things/(?P<pk>[0-9]+)/$", views.ThingView.as_view({"get": "retrieve", "post": "create", "put": "update", "patch": "partial_update", "delete": "destroy"}), name="ticket-detail"),
]