Bug with Django ChoiceField
See original GitHub issueHi, hi
I got one bug using models.CharField
with choices.
Graphene is creating two differents objects as Enum
.
Raising one error in graphene.types.typemap
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 82, in graphene_reducer
return self.construct_objecttype(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 153, in construct_objecttype
map[type._meta.name]._fields = self.construct_fields_for_type(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 214, in construct_fields_for_type
map = self.reducer(map, field.type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 82, in graphene_reducer
return self.construct_objecttype(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 153, in construct_objecttype
map[type._meta.name]._fields = self.construct_fields_for_type(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 214, in construct_fields_for_type
map = self.reducer(map, field.type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 69, in graphene_reducer
return self.reducer(map, type.of_type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 64, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python2.7/dist-packages/graphene-1.1.3-py2.7.egg/graphene/types/typemap.py", line 79, in graphene_reducer
assert _type.graphene_type == type
AssertionError
********************************************************************************
_type.graphene_type UserMobile1Os 139869850885568
type UserMobile1Os 139869850674512
********************************************************************************
My model
MOBILE_PLATFORMS_CHOICES = (
('android', 'Android'),
('ios', 'iOS'),
)
class User(AbstractUser):
full_name = models.CharField(max_length=64, blank=True)
mobile_1_os = models.CharField(max_length=10, default='android',
choices=MOBILE_PLATFORMS_CHOICES,
db_index=True)
My query
class Query(graphene.AbstractType):
users = DjangoConnectionField(
UserNode
)
My UserNode
class UserNode(DjangoObjectType):
class Meta(object):
interfaces = (relay.Node,)
model = User
And I have one file for Schemas
class AllQuery(Query, ObjectType):
viewer = graphene.Field(lambda: AllQuery)
@classmethod
def resolve_viewer(cls, *args, **kwargs):
return AllQuery()
schema_graphene = graphene.Schema(query=AllQuery)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Django choice field unexpected behaviour (bug?)
I came across some weird behaviour in the migrations with Django 1.7. Is this a legitimate bug that should be reported?
Read more >Choices field has a bug - Using Django
I have this model: from django.db import models class TestField(models.Model): M = 'Male' F = 'Female' O = 'Other' GENDER = [ (M,...
Read more >ModelChoiceField and ChoiceField clean methods behave ...
Using both ChoiceField and ModelChoiceField, I discovered a bug in ChoiceField ... I modified the fields.py file in django/newforms, the clean method on...
Read more >#5327 (ChoiceField clean method) – Django - Django's bug tracker
Using both ChoiceField and ModelChoiceField, I discovered a bug in ChoiceField clean method ( or a discrepancy in behaviour). ModelChoiceField seems to be ......
Read more >Form fields - Django documentation
See the model field reference documentation on choices for more details. ... Ticket tracker: Report bugs with Django or Django documentation in our...
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
I have the same issue but I found workaround.
graphene.Enum
See example below. Hope this helps.
another way that I tried and it worked:
No need to excucled the field