mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-23 02:22:08 +03:00
Fix model property
This commit is contained in:
parent
59f4f134b5
commit
609baec3a0
|
@ -20,7 +20,10 @@ class DjangoListField(Field):
|
|||
|
||||
@property
|
||||
def model(self):
|
||||
return self.type.of_type._meta.node._meta.model
|
||||
_type = self.type.of_type
|
||||
if isinstance(_type, NonNull):
|
||||
_type = _type.of_type
|
||||
return _type._meta.model
|
||||
|
||||
@staticmethod
|
||||
def list_resolver(resolver, root, info, **args):
|
||||
|
|
18
graphene_django/tests/test_fields.py
Normal file
18
graphene_django/tests/test_fields.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import pytest
|
||||
from graphene import ObjectType, Schema
|
||||
|
||||
from ..fields import DjangoListField
|
||||
from ..types import DjangoObjectType
|
||||
from .models import Reporter as ReporterModel
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestDjangoListField:
|
||||
def test_get_django_model(self):
|
||||
class Reporter(DjangoObjectType):
|
||||
class Meta:
|
||||
model = ReporterModel
|
||||
fields = ("first_name",)
|
||||
|
||||
list_field = DjangoListField(Reporter)
|
||||
assert list_field.model is ReporterModel
|
Loading…
Reference in New Issue
Block a user