mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 16:40:03 +03:00
Merge remote-tracking branch 'upstream/master' into error-details-tuple
This commit is contained in:
commit
aa77a399cd
|
@ -60,8 +60,8 @@ using the `APIView` class-based views.
|
||||||
|
|
||||||
def get(self, request, format=None):
|
def get(self, request, format=None):
|
||||||
content = {
|
content = {
|
||||||
'user': unicode(request.user), # `django.contrib.auth.User` instance.
|
'user': str(request.user), # `django.contrib.auth.User` instance.
|
||||||
'auth': unicode(request.auth), # None
|
'auth': str(request.auth), # None
|
||||||
}
|
}
|
||||||
return Response(content)
|
return Response(content)
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ Or, if you're using the `@api_view` decorator with function based views.
|
||||||
@permission_classes([IsAuthenticated])
|
@permission_classes([IsAuthenticated])
|
||||||
def example_view(request, format=None):
|
def example_view(request, format=None):
|
||||||
content = {
|
content = {
|
||||||
'user': unicode(request.user), # `django.contrib.auth.User` instance.
|
'user': str(request.user), # `django.contrib.auth.User` instance.
|
||||||
'auth': unicode(request.auth), # None
|
'auth': str(request.auth), # None
|
||||||
}
|
}
|
||||||
return Response(content)
|
return Response(content)
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ If a nested representation may optionally accept the `None` value you should pas
|
||||||
content = serializers.CharField(max_length=200)
|
content = serializers.CharField(max_length=200)
|
||||||
created = serializers.DateTimeField()
|
created = serializers.DateTimeField()
|
||||||
|
|
||||||
Similarly if a nested representation should be a list of items, you should pass the `many=True` flag to the nested serialized.
|
Similarly if a nested representation should be a list of items, you should pass the `many=True` flag to the nested serializer.
|
||||||
|
|
||||||
class CommentSerializer(serializers.Serializer):
|
class CommentSerializer(serializers.Serializer):
|
||||||
user = UserSerializer(required=False)
|
user = UserSerializer(required=False)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user