AssertionError with ViewSets
See original GitHub issueI’m using Python 3.6.3, Django 1.11.6, DRF 3.7.7, version 2.0.1 of this library, and FlatMultipleModelAPIViewSet.
The issue I’m having is:
AssertionError at <URI>
<ViewSet>.get_queryset() returned None
...
Exception Location: <Path>/rest_framework/permissions.py in _queryset, line 126
This is in the code here:
class FlatMultipleModelAPIViewSet(FlatMultipleModelMixin, GenericViewSet):
def get_queryset(self):
return None
And it’s running up against this check:
if hasattr(view, 'get_queryset'):
queryset = view.get_queryset()
assert queryset is not None, (
'{}.get_queryset() returned None'.format(view.__class__.__name__)
)
return queryset
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Assertion error parsing response to POST request from DRF ...
Assertion error parsing response to POST request from DRF viewset with DRF APIClient in tests ... serializers, viewsets router = routers.
Read more >Routers - Django REST framework
Resource routing allows you to quickly declare all of the common routes for a given resourceful controller. Instead of declaring separate routes for...
Read more >Django-Rest-Framework - Obey the Testing Goat!
A router is DRF's way of building URL configuration automatically, and mapping them to the functionality provided by the ViewSet. At this point ......
Read more >Using Different Read and Write Serializers in Django REST ...
The first way we approached using different serializers for read and update actions was to override get_serializer_class() on each viewset to ...
Read more >self.assertEqual(response.status_code, status.HTTP_200_OK ...
HTTP_200_OK) AssertionError: 404 ! ... from rest_framework import generics, mixins, viewsets from rest_framework.filters import SearchFilter from ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hi @amar-muratovic, can you provide some sample code to reproduce the issue? It’s very hard to answer without knowing the specifics of your code.
Also, this seems like a separate issue than the one under discussion here. I’d recommend opening a new issue rather than continuing this current (probably unrelated) discussion.
This pointed me in the right direction, All I really needed was
The only note is that a trailing s was missing.