Adding DjangoModelFormMutation to schema raises import error
See original GitHub issueHi there!
I try to use the awesome DjangoModelFormMutation
but when I add the mutation to the schema I always get this error:
Could not import 'project.config.schema.schema' for Graphene setting 'SCHEMA'. AttributeError: 'NoneType' object has no attribute '_meta'.
Here’s my setup:
class Pet(models.Model):
name = models.CharField()
class PetForm(forms.ModelForm):
class Meta:
model = Pet
fields = ('name',)
class PetMutation(DjangoModelFormMutation):
class Meta:
form_class = PetForm
class PetMutations(graphene.ObjectType):
pet = PetMutation.Field(description="Pets!")
class Mutation(PetMutations,
graphene.ObjectType):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
Any ideas what I might be doing wrong?
Thanks! Ron
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Adding DjangoModelFormMutation to schema raises import ...
django-graphene is trying to import your schema file and is encountering another error along the way. I would recommend doing a manage.py shell...
Read more >Mutations - Graphene-Python
DjangoModelFormMutation will pull the fields from a ModelForm . from graphene_django.forms.mutation import DjangoModelFormMutation class Pet( ...
Read more >Graphene input error for Pydantic models with discriminator ...
I am writing GraphQL APIs and want to convert those pydantic models into graphene input objects. Below is my code. from graphene_pydantic import...
Read more >Graphene Documentation - Read the Docs
We need to add a graphql URL to the urls.py of your Django project: For Django 2.2 and above: from django.urls import path....
Read more >Importerror: No Module Named 'Cython' When Installing ...
Pip install fails with ImportError: No module named Cython. ... graphql-relay2.0.1 Adding DjangoModelFormMutation to schema raises import error hot 8.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aaaaaaaaaaaaaaaaad I found the solution:
I’m going to add this to the documentation 😃
django-graphene is trying to import your schema file and is encountering another error along the way. I would recommend doing a
manage.py shell
and attempt manually importing the schema. This way you can see the import error without other code eating the message.