python - Attribute error when attempting to get a value for field -


i'm working django rest framework , serializer i'm trying use creating errors. i'm trying https://gist.github.com/anonymous/7463dce5b0bfcf9b6767 still error. models

class visitor(models.model):  user = models.onetoonefield(user) check_ins = models.integerfield(default=0)  @classmethod def create(cls, username, email, password):     user = user.objects.create_user(username, email, password)     visitor = cls(user=user)     visitor.save()     return visitor  def __str__(self):     return self.user.username 

and default user class , serializers are

class userserializer(serializers.modelserializer):     class meta:         model=user         fields = ('username')  class visitorserializer(serializers.modelserializer):     user = userserializer()      class meta:         model=visitor         fields = ('id','check_ins','user') 

i error

got attributeerror when attempting value field user on serializer visitorserializer. serializer field might named incorrectly , not match attribute or key on queryset instance. original exception text was: 'queryset' object has no attribute 'user'.

the issue passing queryset serializer without setting many flag. error telling serializer trying access queryset.user when should accessing visitor.user, need tell serializer there multiple objects (instead of single one) passing many=true.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -