fix(api): Dont try to access attribute if not exist in common viewset
ref: #761
This commit is contained in:
@ -87,9 +87,6 @@ class EntityModelTestCases(
|
|||||||
|
|
||||||
yield
|
yield
|
||||||
|
|
||||||
with django_db_blocker.unblock():
|
|
||||||
|
|
||||||
del request.cls.kwargs_create_item
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture( scope = 'class', autouse = True)
|
@pytest.fixture( scope = 'class', autouse = True)
|
||||||
|
@ -839,17 +839,19 @@ class SubModelViewSet(
|
|||||||
is_nested_lookup = True
|
is_nested_lookup = True
|
||||||
|
|
||||||
|
|
||||||
if(
|
|
||||||
|
if not hasattr(related_model, '_meta'):
|
||||||
|
|
||||||
|
related_model = None
|
||||||
|
|
||||||
|
elif(
|
||||||
str(
|
str(
|
||||||
getattr(related_model, '._meta.sub_model_type', '')
|
getattr(related_model._meta, 'sub_model_type', '')
|
||||||
).lower().replace(' ', '_') == model_kwarg
|
).lower().replace(' ', '_') == model_kwarg
|
||||||
):
|
):
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
||||||
else:
|
|
||||||
|
|
||||||
related_model = None
|
|
||||||
|
|
||||||
|
|
||||||
if related_model is None and not is_nested_lookup:
|
if related_model is None and not is_nested_lookup:
|
||||||
|
Reference in New Issue
Block a user