diff options
| author | Tom Christie | 2014-09-29 21:17:13 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-29 21:17:13 +0100 |
| commit | 83a5ea8db27b9452a5539f1e0574f493392a91ad (patch) | |
| tree | f7d948a977706c0269e0550949616f694b198c5a | |
| parent | d1b2c8ac7faec65483cbddf4f1718ca4f5805246 (diff) | |
| download | django-rest-framework-83a5ea8db27b9452a5539f1e0574f493392a91ad.tar.bz2 | |
Update release notes
| -rw-r--r-- | docs/topics/3.0-announcement.md | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/docs/topics/3.0-announcement.md b/docs/topics/3.0-announcement.md index 584c4979..12ab5a0d 100644 --- a/docs/topics/3.0-announcement.md +++ b/docs/topics/3.0-announcement.md @@ -664,14 +664,26 @@ The `COMPACT_JSON` setting has been added, and can be used to revert this behavi #### File fields as URLs -The `FileField` and `ImageField` classes are now represented as URLs by default. You should ensure you set Django's standard `MEDIA_URL` setting appropriately. +The `FileField` and `ImageField` classes are now represented as URLs by default. You should ensure you set Django's [standard `MEDIA_URL` setting](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-MEDIA_URL) appropriately, and ensure your application [serves the uploaded files](https://docs.djangoproject.com/en/dev/howto/static-files/#serving-uploaded-files-in-development). -You can revert this behavior, and display filenames as the representation, using the `UPLOADED_FILES_USE_URL` settings key: +You can revert this behavior, and display filenames in the representation by using the `UPLOADED_FILES_USE_URL` settings key: REST_FRAMEWORK = { 'UPLOADED_FILES_USE_URL': False } +You can also modify serializer fields individually, using the `use_url` argument: + + uploaded_file = serializers.FileField(user_url=False) + +Also note that you should pass the `request` object to the serializer as context when instantiating it, so that a fully qualified URL can be returned. Returned URLs will then be of the form `https://example.com/url_path/filename.txt`. For example: + + context = {'request': request} + serializer = ExampleSerializer(instance, context=context) + return Response(serializer.data) + +If the request is omitted from the context, the returned URLs will be of the form `/url_path/filename.txt`. + #### Throttle headers using `Retry-After`. The custom `X-Throttle-Wait-Second` header has now been dropped in favor of the standard `Retry-After` header. You can revert this behavior if needed by writing a custom exception handler for your application. |
