mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
This commit is contained in:
commit
afc9e9e038
|
@ -59,7 +59,7 @@ using the `APIView` class based views.
|
|||
Or, if you're using the `@api_view` decorator with function based views.
|
||||
|
||||
@api_view('GET')
|
||||
@throttle_classes(UserRateThrottle)
|
||||
@throttle_classes([UserRateThrottle])
|
||||
def example_view(request, format=None):
|
||||
content = {
|
||||
'status': 'request was permitted'
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
## Javascript clients
|
||||
|
||||
If your building a javascript client to interface with your Web API, you'll need to consider if the client can use the same authentication policy that is used by the rest of the website, and also determine if you need to use CSRF tokens or CORS headers.
|
||||
If you’re building a JavaScript client to interface with your Web API, you'll need to consider if the client can use the same authentication policy that is used by the rest of the website, and also determine if you need to use CSRF tokens or CORS headers.
|
||||
|
||||
AJAX requests that are made within the same context as the API they are interacting with will typically use `SessionAuthentication`. This ensures that once a user has logged in, any AJAX requests made can be authenticated using the same session-based authentication that is used for the rest of the website.
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ You can determine your currently installed version using `pip freeze`:
|
|||
* 'Raw data' and 'HTML form' tab preference in browseable API now saved between page views.
|
||||
* Bugfix: `required=True` argument fixed for boolean serializer fields.
|
||||
* Bugfix: `client.force_authenticate(None)` should also clear session info if it exists.
|
||||
* Bugfix: Client sending emptry string instead of file now clears `FileField`.
|
||||
* Bugfix: Client sending empty string instead of file now clears `FileField`.
|
||||
* Bugfix: Empty values on ChoiceFields with `required=False` now consistently return `None`.
|
||||
|
||||
### 2.3.7
|
||||
|
|
|
@ -306,6 +306,7 @@ class WritableField(Field):
|
|||
return
|
||||
|
||||
try:
|
||||
data = data or {}
|
||||
if self.use_files:
|
||||
files = files or {}
|
||||
try:
|
||||
|
|
|
@ -80,3 +80,16 @@ class FileSerializerTests(TestCase):
|
|||
serializer = UploadedFileSerializer(data={'created': now, 'file': 'abc'})
|
||||
self.assertFalse(serializer.is_valid())
|
||||
self.assertEqual(serializer.errors, {'file': [errmsg]})
|
||||
|
||||
def test_validation_with_no_data(self):
|
||||
"""
|
||||
Validation should still function when no data dictionary is provided.
|
||||
"""
|
||||
now = datetime.datetime.now()
|
||||
file = BytesIO(six.b('stuff'))
|
||||
file.name = 'stuff.txt'
|
||||
file.size = len(file.getvalue())
|
||||
uploaded_file = UploadedFile(file=file, created=now)
|
||||
|
||||
serializer = UploadedFileSerializer(files={'file': file})
|
||||
self.assertFalse(serializer.is_valid())
|
||||
|
|
Loading…
Reference in New Issue
Block a user