-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default to default actions of view if .as_view(actions=None) #3742
Comments
What is the problem you are referring to ? |
That the actions dictionary needs to be passed when using .as_view() on ModelViewSet and ReadOnlyModelViewSet views even though those particular view types have default actions defined. |
Something like this could work in rest_framework/viewsets.py i think: # actions must not be empty
if not actions:
if cls.__base__ is ModelViewSet:
# actions = ModelViewSet default actions
elif cls.__base__ is ReadOnlyModelViewSet:
# actions = ReadOnlyModelViewSet
else:
raise TypeError("The `actions` argument must be provided when "
"calling `.as_view()` on a ViewSet. For example "
"`.as_view({'get': 'list'})`") See #2175 for code placement. I have to try some more things that I don't have time for right now before making a pull request. |
Actually, the two you mentioned should have the actions argument. |
thank You so much. You saved my time |
In the latest Django stable one can't use patterns() anymore:
This was quite nice as one didn't have to pass default actions to views with default actions. When doing the following today:
We get a warning from the .as_view() override due to the way that #2171 was solved with #2175:
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:
The text was updated successfully, but these errors were encountered: