mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 21:40:13 +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.
|
||||
"""
|
||||
queryset = getattr(viewset, 'queryset', None)
|
||||
|
||||
assert queryset is not None, '`base_name` argument not specified, and could ' \
|
||||
model = getattr(viewset, 'model', None)
|
||||
|
||||
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 ' \
|
||||
'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):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user