mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
Docs tweaks.
This commit is contained in:
parent
5f065153c3
commit
1929159db1
|
@ -240,7 +240,9 @@ Signature and validation is the same as with `FileField`.
|
||||||
---
|
---
|
||||||
|
|
||||||
**Note:** `FileFields` and `ImageFields` are only suitable for use with MultiPartParser, since e.g. json doesn't support file uploads.
|
**Note:** `FileFields` and `ImageFields` are only suitable for use with MultiPartParser, since e.g. json doesn't support file uploads.
|
||||||
Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files.
|
Django's regular [FILE_UPLOAD_HANDLERS] are used for handling uploaded files.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
|
[cite]: https://docs.djangoproject.com/en/dev/ref/forms/api/#django.forms.Form.cleaned_data
|
||||||
[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS
|
[FILE_UPLOAD_HANDLERS]: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FILE_UPLOAD_HANDLERS
|
||||||
|
|
|
@ -190,18 +190,12 @@ By default field values are treated as mapping to an attribute on the object. I
|
||||||
|
|
||||||
As an example, let's create a field that can be used represent the class name of the object being serialized:
|
As an example, let's create a field that can be used represent the class name of the object being serialized:
|
||||||
|
|
||||||
class ClassNameField(serializers.WritableField):
|
class ClassNameField(serializers.Field):
|
||||||
def field_to_native(self, obj, field_name):
|
def field_to_native(self, obj, field_name):
|
||||||
"""
|
"""
|
||||||
Serialize the object's class name, not an attribute of the object.
|
Serialize the object's class name.
|
||||||
"""
|
"""
|
||||||
return obj.__class__.__name__
|
return obj.__class__
|
||||||
|
|
||||||
def field_from_native(self, data, field_name, into):
|
|
||||||
"""
|
|
||||||
We don't want to set anything when we revert this field.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user