mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
change router to take base name from model along with queryset
This commit is contained in:
parent
c5b4be701a
commit
0e039402b2
|
@ -133,12 +133,14 @@ class SimpleRouter(BaseRouter):
|
||||||
it from the viewset.
|
it from the viewset.
|
||||||
"""
|
"""
|
||||||
queryset = getattr(viewset, 'queryset', None)
|
queryset = getattr(viewset, 'queryset', None)
|
||||||
|
model = getattr(viewset, 'model', None)
|
||||||
assert queryset is not None, '`base_name` argument not specified, and could ' \
|
|
||||||
|
assert ((queryset is not None) or (model is not None)), '`base_name` argument not specified, and could ' \
|
||||||
'not automatically determine the name from the viewset, as ' \
|
'not automatically determine the name from the viewset, as ' \
|
||||||
'it does not have a `.queryset` attribute.'
|
'it does not have a `.queryset` attribute.'
|
||||||
|
|
||||||
return queryset.model._meta.object_name.lower()
|
model = model if model is not None else queryset.model
|
||||||
|
return model._meta.object_name.lower()
|
||||||
|
|
||||||
def get_routes(self, viewset):
|
def get_routes(self, viewset):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user