Rest Framework SerializerMutation Error - NoneType is not callable
See original GitHub issueHi, I’m using the SerializerMutation class to attempt to create mutations based off of my existing Rest Framework serializers. By taking advantage of the ModelSerializer in DRF, I hoped to avoid having to create all the mutations from scratch with validation and whatnot.
However, the use of the SerializerMutation class isn’t sufficiently explained in the docs. I did this
class ItemMutation(SerializerMutation):
class Meta:
serializer_class = ItemSerializer
class Mutation(AbstractType):
#...other mutations...
createItem = ItemMutation.Field()
from a simple DRF ModelSerializer
class ItemSerializer(serializers.ModelSerializer):
class Meta:
model = Item
fields = (
'id',
'name',
'description',
'website',
)
But Graphiql shows me the following error whenever I try to use the mutation
mutation newItem($data: ItemMutationInput!) {
createItem(input: $data) {
name,
description
}
}
{
"data": {
"name": "Blah",
"description": "Blah blah blah",
"website": "https://blah.blah.blah"
}
}
{
"errors": [
{
"message": "'NoneType' object is not callable",
"locations": [
{
"line": 2,
"column": 3
}
]
}
],
"data": {
"createItem": null
}
}
Also, Rest Framework’s serializers can often have multiple actions (mutations) like create, delete, update, etc and the use of SerializerMutation appears to just produce a single mutation - presumably the “create” action. How do I handle the other actions?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
TypeError: 'NoneType' object is not callable using restframework
I'm building a customer user using restframework, but I get this error: TypeError: 'NoneType' object is not callable.
Read more >TypeError: 'NoneType' object is not callable : r/django - Reddit
The first error is that self. model is not defined, so you can't call it. Replace it with CustomUser or (better) the result...
Read more >'NoneType' object is not callable (smart_unicode is None)
This seems to be some kind of magic import related bug, since there doesn't seem to be any natural way for the symbol...
Read more >"TypeError: 'NoneType' object is not callable" when building ...
I've verified it in both Python 3.10.0 and 3.10.2 with files mapped to my project venv. My app makes a request to an...
Read more >TypeError: 'NoneType' object is not callable in Python
The Python TypeError: 'NoneType' object is not callable occurs when we try to call a `None` value as if it were a function....
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
@abdulhaq-e there was no release of 1.x with SerializerMutation. It was added in July and the most recent 1.x release was 1.3 in April.
For anyone who is interested I opened #261 to try to get SerializerMutation working again for 2.x
There must’ve been something wrong with publishing. I didn’t experience it because I had a similar scenario as yours where I had a local copy of
graphene-django
in my app rather than the version on PyPy.