graphene-django: AttributeError: 'NoneType' object has no attribute '_meta'
I have simple graphene based django project: https://github.com/aliev/graphene-django-bug
For some reason when I’m trying to run server or make migrations I have an exception:
AttributeError: 'NoneType' object has no attribute '_meta'
I’m using model forms and DjangoModelFormMutation
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 17 (2 by maintainers)
I’m having the same issue with the rest framework
SerializerMutationI’ve narrowed it down to that I need to
importonly those types that have a relation (ForeignKeyorOneToOne) to another type. Would you like me to provide a simple example to reproduce the issue, would that help?@phalt this bug is still current AFAIK. Not sure why this has been closed? To confirm, when putting mutations into a Python file separate from the type definitions I need to
importall the types related to the mutations at the top of the file. Even though I don’t use them. OtherwiseAttributeError: 'NoneType' object has no attribute '_meta'is raised when running unit tests.In my root
schema.pyfile, I imported the mutation before the query which resulted in an error. Putting query import before mutation imports resolved the issue for meSame problem here, it happens when I define types in separate files.
In my case the error originated from defining the SerializerMutation class before the Type class which I needed in the SerializerMutation. After moving all schema types above the mutations it worked.