You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using DocumentSerializer to do the job, and I got this message when I was trying to serialize a mongo model object:
/usr/local/lib/python3.6/site-packages/rest_framework_mongoengine/serializers.py in __repr__(self)
797
798 def __repr__(self):
--> 799 return serializer_repr(self, indent=1)
800
801
/usr/local/lib/python3.6/site-packages/rest_framework_mongoengine/repr.py in serializer_repr(serializer, indent, force_many)
105 fields = force_many.fields
106 else:
--> 107 fields = serializer.fields
108
109 for field_name, field in fields.items()
/usr/local/lib64/python3.6/site-packages/django/utils/functional.py in __get__(self, instance, cls)
46 if instance is None:
47 return self
---> 48 res = instance.__dict__[self.name] = self.func(instance)
49 return res
50
/usr/local/lib/python3.6/site-packages/rest_framework/serializers.py in fields(self)
361 # even if Django's app-loading stage has not yet run.
362 fields = BindingDict(self)
--> 363 for key, value in self.get_fields().items():
364 fields[key] = value
365 return fields
/usr/local/lib/python3.6/site-packages/rest_framework_mongoengine/serializers.py in get_fields(self)
324
325 # Retrieve metadata about fields & relationships on the model class.
--> 326 self.field_info = get_field_info(model)
327 field_names = self.get_field_names(declared_fields, self.field_info)
328 # Determine any extra field arguments and hidden fields that
/usr/local/lib/python3.6/site-packages/rest_framework_mongoengine/utils.py in get_field_info(model)
64 pk = None
65 else:
---> 66 pk = model._fields[model._meta['id_field']]
67
68 # Deal with regular fields.
AttributeError: type object 'XXX' has no attribute '_fields'
then I ran the django shell and realized the model has no "_fields" attribute, how does this even work?
And by the way, my model is inherit from djongo's model
The text was updated successfully, but these errors were encountered:
I'm using DocumentSerializer to do the job, and I got this message when I was trying to serialize a mongo model object:
then I ran the django shell and realized the model has no "_fields" attribute, how does this even work?
And by the way, my model is inherit from djongo's model
The text was updated successfully, but these errors were encountered: