Hello,
Not sure what the difference is in the usage of attrs
I could not find the documentation for this although I'm sure it's going to
be obvious after the fact.
Also, could someone tell me what the double asterisks mean in the line
return Comment(**attrs)
?
Is this some type of variable length parameter list? How would
return Comment(*attrs)
and
return Comment(attrs)
vs
be different?
Thank you!
class CommentSerializer(serializers.Serializer):
email = serializers.EmailField()
content = serializers.CharField(max_length=200)
created = serializers.DateTimeField()
def restore_object(self, attrs, instance=None):
if instance is not None:
instance.title = attrs['title']
instance.content = attrs['content']
instance.created = attrs['created']
return instance
return Comment(**attrs)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.