Commit Graph

1542 Commits

Author SHA1 Message Date
Tom Christie
4edd39b2e4 Merge pull request #1442 from Anton-Shutik/master
RelatedField default value handling fixed
2014-03-04 15:26:34 +00:00
Anton Shutik
dea2766aba Added tests for "get_default_value" function 2014-03-04 13:11:54 +03:00
Xavier Ordoquy
3d7cb72e0a Merge remote-tracking branch 'reference/master' into feature/django_1_7 2014-03-03 11:41:07 +01:00
hongfeiZhang
693d9d9c63 In the method permission_denied, did not use the request parameter. 2014-03-01 11:37:31 +08:00
Tom Christie
22f225175f Merge pull request #1437 from Keats/master
Display the media type of the API response on the browsable API
2014-02-28 11:55:45 +00:00
Anton Shutik
3c62f0efc3 RelatedField.get_default_value: return empty list if self.many==True 2014-02-28 13:59:21 +03:00
Tom Christie
c3c69f4304 Merge pull request #1441 from dustinfarris/null-serialization
TestCases and POST/PUT'ing serialized data that contains `None`
2014-02-28 09:27:27 +00:00
Val Neekman
818b4bf8b3 handle negative time value and prevent a divide by zero 2014-02-27 12:27:54 -08:00
Dustin Farris
f126856f65 Allow 'None' to pass as a null value in RelatedFields 2014-02-27 12:30:59 -05:00
Anton Shutik
1addd09e2b RelatedField default value handling fixed 2014-02-27 18:34:36 +03:00
Keats
6cd0394e20 Display the media type of the API response on the browsable API 2014-02-26 23:47:35 +00:00
Dustin Farris
505f1173d0 Demonstrate problem post/put'ing serialized data that contains 'None' 2014-02-26 12:08:26 -05:00
Tom Christie
d328f1827d Tweak comment wrapping. 2014-02-18 12:30:55 +00:00
Ian Foote
dca8b98356 Remove unnecessary else 2014-02-18 12:28:02 +00:00
Ian Foote
f22aeeb0a3 Refactor UpdateModelMixin.update
Reduce nesting, return early in error cases.
2014-02-18 12:08:12 +00:00
Xavier Ordoquy
b2f0f4fcf4 Merge remote-tracking branch 'reference/master' into feature/django_1_7 2014-02-18 11:42:35 +01:00
Xavier Ordoquy
5ae94547bc Moved the python_2_unicode_compatible into compat module. 2014-02-18 11:42:17 +01:00
tuky
5e4336845f Update throttling.py
python 3 u'' gone
2014-02-14 13:47:17 +01:00
Tom Christie
a06252f812 Merge pull request #1397 from amezhenin/issue_1386
update regex for matching URLs, fixes issue #1386
2014-02-13 16:27:19 +00:00
Artem Mezhenin
dbd993d108 wrapper for smart_urlquote, issue #1386 2014-02-13 20:14:47 +04:00
Artem Mezhenin
08ec23268d (I hope) tests are fixed, issue #1386 2014-02-13 19:39:53 +04:00
Artem Mezhenin
d00ea3bcac change regex back, issue #1386 2014-02-13 18:59:05 +04:00
tuky
d18d32669a remove spaces from META['HTTP_X_FORWARDED_FOR'] as throttle key
memcached cannot handle spaces in keys
2014-02-12 18:11:18 +01:00
Carlton Gibson
f1016441f5 Test and fix for #1210. World's lowest hanging fruit. 2014-02-11 19:52:32 +01:00
Carlton Gibson
95670933d7 Test and quick fix for #1257 2014-02-11 14:44:56 +01:00
Hassan Shamim
97b7c25987 Replace 'detail' with 'default_detail' in Exceptions guide and APIException class docstring. 2014-02-10 12:54:56 -06:00
Artem Mezhenin
35f4908e48 issue #1386
* regex for matching URLs was rewritten
* added unittests
2014-02-09 02:46:25 +04:00
Artem Mezhenin
41eb313e1c update regex for matching URLs, fixes issue #1386 2014-02-09 01:01:05 +04:00
Matthew King
f8cda8adbd Generate random token directly 2014-02-04 22:50:11 -05:00
juroe
b182b9e246 Fixes typo (Implicit instead of Implict). 2014-02-04 11:56:41 +01:00
Tom Christie
8f921160e5 Merge pull request #1377 from Ian-Foote/force_bytes
Import force_bytes on django >= 1.5
2014-01-31 03:45:04 -08:00
Xavier Ordoquy
5a662dd60e Moving models back to test_serializer. 2014-01-31 11:20:53 +01:00
Ian Foote
0043f30cab Use bytes BOUNDARY on django < 1.5
Django's encode_multipart was updated in django 1.5 to work internally
with unicode and convert to bytes.

In django >= 1.5 we therefore need to pass the BOUNDARY as unicode. In
django < 1.5 we still need to pass it as bytes.
2014-01-31 09:12:45 +00:00
Tom Christie
18f26ff5cc Only add 'Vary: Accept' header when there is more than one possible renderer. 2014-01-30 17:47:55 +00:00
Tom Christie
9f0ead9597 Remove TODO note, since it hasn't been TODONE. 2014-01-30 17:32:05 +00:00
Xavier Ordoquy
73e5b7e4b2 Fixed the object representation in order to pass the tests. 2014-01-30 14:27:46 +01:00
Xavier Ordoquy
c2ee52239d Refactoring due to the previous commit. 2014-01-30 14:27:09 +01:00
Xavier Ordoquy
1319da59ce Make factory.get work with Django 1.7 2014-01-30 14:26:21 +01:00
Xavier Ordoquy
c6d89afdf7 Define the upload_to for file fields. 2014-01-28 23:43:09 +01:00
Xavier Ordoquy
e4c25e0ff2 wsgi_request is now added to the response so we have to remove it before pickling the response. 2014-01-28 18:57:36 +01:00
Xavier Ordoquy
656117814c Django 1.7 has new 404 and 403 body messages. 2014-01-28 18:55:29 +01:00
Xavier Ordoquy
23a20160c4 Mock updated as Django’s get_template now has two arguments. 2014-01-28 18:54:49 +01:00
Xavier Ordoquy
da89cfc937 Don’t rely on Django’s get as it breaks for 1.7 2014-01-28 18:53:58 +01:00
Xavier Ordoquy
6aadd1639b Moved all the reused models to the models files to avoid conflicts with the refactored apps. 2014-01-28 18:53:24 +01:00
Ian Foote
78e4468f03 Add file upload test for APIRequestFactory
Remove test_compat
2014-01-28 15:54:50 +00:00
Ian Foote
74fec7eeb4 Import force_bytes on django >= 1.5 2014-01-28 14:30:46 +00:00
Xavier Ordoquy
7713ddc0a8 Don’t forget to setup django for 1.7+ as it’s not a regular django command. 2014-01-28 13:20:51 +01:00
Rodolfo Henrique Carvalho
c436725dd6 Fix typo in docstring for post_delete hook. 2014-01-25 23:58:42 +01:00
Tom Christie
47f5bd488d Merge pull request #1361 from ross/x_method_override
always obey X-HTTP-METHOD-OVERRIDE header
2014-01-17 08:19:06 -08:00
Ross McFarland
58d77c11c3 always obey X-HTTP-METHOD-OVERRIDE header
required to support old flash/flex clients that need to do everything as
GET requests (apparently to allow for any error handlings)
2014-01-17 08:14:05 -08:00
Mathieu Pillard
f034cb595a Encode django QuerySets to lists and not dicts in JSONEncoder 2014-01-17 13:05:10 +01:00
Tom Christie
71c03b9db9 Security update to OrderingFilter 2014-01-15 14:27:41 +00:00
Tom Christie
e9fda70b4a Nicer write_only fields implementation. Closes #1355 2014-01-15 08:53:23 +00:00
Tom Christie
8f6983ee6e Merge branch 'master' of git://github.com/sprymak/django-rest-framework into sprymak-master 2014-01-14 20:35:26 +00:00
Tom Christie
dde3b1dfcb Use api_settings.URL_FIELD_NAME 2014-01-14 20:35:09 +00:00
S.Prymak
ed8143b2b0 Test for customizable HyperlinkedModelSerializer url field name 2014-01-14 13:58:17 +02:00
Tom Christie
97f8ede4d1 Version 2.3.11 2014-01-14 11:26:10 +00:00
Tom Christie
85d74fc86a Added write_only and write_only_fields. Refs #1306 2014-01-14 11:25:44 +00:00
S.Prymak
e9b0d70f5d Override HyperlinkedModelSerializerOptions url field name with URL_FIELD_NAME setting 2014-01-14 10:38:49 +02:00
Tom Christie
bc6c5df109 Minor tweaks 2014-01-13 17:39:22 +00:00
Tom Christie
e91d0a69ab Merge branch 'testing-nested-serializers' of git://github.com/dustinfarris/django-rest-framework into dustinfarris-testing-nested-serializers 2014-01-13 17:38:03 +00:00
Tom Christie
d937ce331c Minor cleanup 2014-01-13 17:37:08 +00:00
Dustin Farris
c4d77667cf Move ImportingModelSerializerTests and add comments. 2014-01-13 12:03:13 -05:00
Tom Christie
73d8a2bcbd Merge branch 'master' of git://github.com/cguethle/django-rest-framework into cguethle-master 2014-01-13 16:52:19 +00:00
Dustin Farris
b1b58762a3 Move models.resolve_model to serializers._resolve_model 2014-01-13 11:47:44 -05:00
S.Prymak
65858428fd Make HyperlinkedModelSerializer url field name customizable 2014-01-13 16:35:20 +02:00
Dustin Farris
2332382b51 Add a sanity check to avoid running into unresolved related models. 2014-01-12 20:28:19 -05:00
Xavier Ordoquy
f217f6870d Removed useless try/except 2014-01-09 23:32:50 +01:00
Xavier Ordoquy
a7072eb730 Test case for #1129 2014-01-09 23:19:25 +01:00
Dustin Farris
bf5b77ce6d Move serializer import to top-level causes test error 2014-01-09 11:42:41 -05:00
Tom Christie
c6182b78e5 Merge pull request #1341 from fredrikmollerstrand/docstring-typo-fix
fix docstring typos.
2014-01-09 07:51:02 -08:00
Fredrik Möllerstrand
82a48ca55e fix docstring typos. 2014-01-09 15:41:20 +00:00
Dustin Farris
52db4eadc2 Testing nested serializers with models that have str foreign key references. 2014-01-08 16:14:27 -05:00
Tom Christie
78494401c5 Use www.django-rest-framework.org for docs instead of django-rest-framework.org due to issues with naked domains 2014-01-08 15:22:41 +00:00
Tom Christie
e3ae33017d Added "nofollow" against docs link. 2014-01-06 15:01:45 +00:00
Steven Cummings
e020c51b44 FIX BaseSerializer.from_native has an altered signature
* base classes define it with one parameter
* BaseSerializer currently defines a second parameter, which we make optional here for method-dispatch passivity
2014-01-02 17:18:08 -06:00
S. Andrew Sheppard
d30ce2575c fix for genericrelation saving 2013-12-23 22:31:31 -06:00
S. Andrew Sheppard
25bd6d1d4b can't save genericrelations via nested serializers in django 1.6 2013-12-23 22:27:40 -06:00
Tom Christie
feddd16c54 Tweak test style 2013-12-23 12:04:17 +00:00
Tom Christie
3f5e3c28f5 Updated tests to pass in python 3 2013-12-23 11:55:25 +00:00
Yin Jifeng
80e9f0d64b fix url double quoted in Django 1.6
get_full_path returns unicode, so we use build_absolute_uri which
returns iri_to_uri'ed one
2013-12-23 14:33:53 +08:00
amatellanes
2d6d725c2f Simplified some functions 2013-12-22 12:39:47 +01:00
Tom Christie
b7482629c3 Merge pull request #1309 from lukaszb/errors-for-renamed-fields
Should it be that way?
2013-12-21 13:58:49 -08:00
Tom Christie
71ab7cda2a Additional test for 'source' behaviour. Refs #1302 2013-12-21 21:54:51 +00:00
Tom Christie
a439c80cd8 Less brittle through relationship testing. Closes #1292. 2013-12-21 21:21:53 +00:00
Lukasz Balcerzak
973f898a4b Should it be that way? 2013-12-20 17:45:56 +01:00
Tom Christie
46906b2bdc Merge pull request #1308 from lukaszb/missing-custom-validation-method-test
Added missing custom validation method test
2013-12-20 08:37:30 -08:00
Lukasz Balcerzak
71aa5f3c45 Added missing custom validation method test 2013-12-20 17:16:24 +01:00
Lukasz Balcerzak
0e3822d6e0 Updated test class name to be unique 2013-12-20 16:53:06 +01:00
Tom Christie
8894019899 Merge branch 'nullbooleanfield_testcase' of git://github.com/dpetzel/django-rest-framework into dpetzel-nullbooleanfield_testcase
Conflicts:
	rest_framework/tests/test_serializer.py
2013-12-16 13:51:57 +00:00
Tom Christie
0f37260254 Merge pull request #1184 from dpetzel/nullbooleanfield_fix
Fix infered field type for models.NullBooleanField
2013-12-16 05:50:10 -08:00
Tom Christie
4bc829d4e9 Merge pull request #1298 from craigds/fix-nested-serializers-with-renamed-fields
Fix nested serializers with renamed fields
2013-12-16 01:18:31 -08:00
Tom Christie
fc2dee844a Don't import compat.py from authtoken.models. Closes #1297 2013-12-16 08:59:10 +00:00
Craig de Stigter
4a134eefa2 Fix expansion of writable nested serializers where the inner fields have source set. 2013-12-16 15:55:54 +13:00
Tom Christie
a87c55a93a Compat fixes for django-oauth-plus versions 2.0-2.2.1 2013-12-13 21:57:07 +00:00
Tom Christie
fac6d1a36e Merge branch 'master' of git://github.com/philipforget/django-rest-framework into philipforget-master 2013-12-13 20:40:11 +00:00
Tom Christie
193af483ef Add notes on lookup_prefix argument and why it's there even though unused by the default implementations. 2013-12-13 20:22:56 +00:00
Tom Christie
fbaba0a309 Merge pull request #1281 from alanjds/router-prefix-patch
'lookup_prefix' on SimpleRouter.get_lookup_regex, easing code de-duplication
2013-12-13 12:19:49 -08:00
Kevin Brown
90edcbf938 Fix default values always being False for browsable API
This fixes a bug that was introduced in 28ff6fb [1] for the
browsable API, specifically with how it handled default values
for boolean fields.  Previously, it had a global default for
boolean fields set to `False`, which was different than the
standard None that was used elsewhere.  Because this only needed
to be done for the browsable API, a fix was put into place that
only set the default to `False` when form data was passed into
the serializer.  This had the unintended side effect of overriding
any default set on the boolean field.

This fixes #1101 [2] by only overriding the default if the default is
`None`, which is the default for all fields.

[1]: 28ff6fb1ec
[2]: https://github.com/tomchristie/django-rest-framework/issues/1101
2013-12-13 13:20:29 -05:00
Tom Christie
0453cbd56b Clean up implementation 2013-12-13 11:09:54 +00:00
Tom Christie
a129bdd0f0 Merge pull request #1234 from linovia/bugfix/nested_models_without_related_name
Fixed the nested model serializers in case of the related_name isn’t set...
2013-12-13 03:06:14 -08:00
Alan Justino
d3a118c728 SimpleRouter.get_lookup_regex got lookup_prefix
This allows @alanjds/drf-nested-routers to not duplicate/monkeypatch work made here
2013-12-10 17:14:17 -02:00
Tom Christie
3a1c40f814 Refine model manager behavior so as not to use the behavior in incorrect cases. Closes #1205 2013-12-10 08:46:44 +00:00
Tom Christie
ddd17c69e7 Fix compat issues for #1231 2013-12-09 09:24:10 +00:00
Tom Christie
a6ca943faa Merge branch 'issue-1231-jsonencoder' of git://github.com/mbox/django-rest-framework into mbox-issue-1231-jsonencoder 2013-12-09 08:50:31 +00:00
Tom Christie
80ef2685e5 Merge master 2013-12-09 07:45:45 +00:00
Tom Christie
4e9385e709 Drop unneeded assert 2013-12-09 07:37:13 +00:00
Tom Christie
06d8a31e13 Catch and mask ParseErrors that occur during rendering of the BrowsableAPI. 2013-12-09 07:34:08 +00:00
Tom Christie
910de38a9c Version 2.3.10 2013-12-06 22:13:50 +00:00
Chuck Harmston
cf6c11bd4b Raise appropriate error in serializer when making a partial update to set a required RelatedField to null (issue #1158) 2013-12-06 14:00:23 -06:00
Tom Christie
1f8069c0a9 Boilerplate cuteness 2013-12-05 11:05:25 +00:00
Tom Christie
38d78b21c0 Remove Content-Type header from empty responses. Fixes #1196 2013-12-03 16:55:11 +00:00
Tom Christie
774298f145 First pass at a test for ParseErrors breaking the browsable API 2013-12-03 16:18:35 +00:00
Tom Christie
344cd865ab Merge pull request #1250 from Ian-Foote/choice_field
Add choices to options metadata for ChoiceField.
2013-12-03 08:03:02 -08:00
Tom Christie
c1d9a96df0 Catch errors during parsing and set empty .DATA/.FILES before re-raising. 2013-12-03 08:58:05 +00:00
Pablo Recio
699ec7236b Adds pre_delete and post_delete hooks on 2013-12-03 00:07:41 +00:00
Omer Katz
b8f8fb7779 Updated the assertion message of the ImageField. 2013-11-27 13:26:49 +02:00
Ian Foote
8d09f56061 Add unittests for ChoiceField metadata.
Rename 'name' to 'display_name'.
2013-11-27 11:06:42 +00:00
Ian Foote
2484fc9141 Add more context to the ChoiceField metadata. 2013-11-26 17:10:16 +00:00
Ian Foote
a38d9d5b24 Add choices to options metadata for ChoiceField. 2013-11-26 09:33:47 +00:00
Malcolm Box
6af31ed394 Remove u from literals 2013-11-22 10:59:48 +00:00
Malcolm Box
263281d71d Fix issue #1231: JSONEncoder doesn't handle dict-like objects
Check for __getitem__ and then attempt to convert to a dict.
The check for __getitem__ is there as there's no universal way to
check if an object is a mapping type, but this is a likely proxy
2013-11-21 20:09:48 +00:00
Tom Christie
43c4e3aab8 Merge pull request #1229 from jgomezb/patch-2
Update urlpatterns.py
2013-11-21 01:43:07 -08:00
Krzysztof Jurewicz
9cea6880f7 Added handling of validation errors in PUT-as-create.
Fixes #1035.
2013-11-19 15:49:31 +01:00
Xavier Ordoquy
88f5921f2f Removed the DynamicSerializerView duplication 2013-11-18 20:15:35 +01:00
Xavier Ordoquy
a8b15f4290 Another fix for nested writable serializers in case of the related_name isn’t set on the ForeignKey. 2013-11-18 15:11:29 +01:00
Xavier Ordoquy
ad7aa8fe48 Fixed the nested model serializers in case of the related_name isn’t set. 2013-11-17 01:27:16 +01:00
Philip Forget
b86765d9c0 add auth param to request client calls 2013-11-15 12:25:32 -05:00
Tom Christie
7a0e2ed6f6 Version 2.3.9 2013-11-15 13:55:36 +00:00
Philip Forget
5239362951 pass oauth_timestamp to oauth_provider 2013-11-14 18:02:07 -05:00
jgomezb
6be62bc1d7 Update urlpatterns.py
Allow numbers in format extension.
2013-11-14 09:22:07 +01:00
Alex
e29942948f Undo version bump 2013-11-13 12:06:59 +00:00
Alex
f4e610248b Bump version 2013-11-12 23:46:01 +00:00
Alex
5136798a04 Merge branch 'master' into allow-aggregate-ordering 2013-11-12 23:40:24 +00:00
Alex
d1dc68d755 Add queryset aggregates to allowed fields in OrderingFilter 2013-11-12 23:40:07 +00:00
Doğan Çeçen
fd2c291c4d Typo on api-guide/fields.md and serializers.py 2013-11-11 11:54:30 +02:00
Tom Christie
470134ae9b Merge pull request #1217 from benpbenp/master
Fix object creation with reverse M2M when related_name unspecified
2013-11-08 07:15:40 -08:00
Ben Pietravalle
b7b57adee2 Fix object creation with reverse M2M when related_name unspecified
It seems that field.related_query_name() does not return the related_name
for reverse M2M relations when related_name is not explicitly set in the M2M field
definition.

So, change to use obj.get_accessor_name(), where obj is an instance of
RelatedObject, as are returned by a model's
_meta.get_all_related_many_to_many_objects(), or as in the tuples returned by
_meta.get_all_m2m_objects_with_model().
2013-11-08 13:19:40 +00:00
Xavier Ordoquy
d4a50429b0 Fixed a regression with ValidationError under Django 1.6 2013-11-08 13:12:40 +01:00
Mathieu Pillard
5829eb7a5b Drop u'' prefix for python 3.x compatibility 2013-11-06 12:51:40 +01:00
Mathieu Pillard
5325890821 Improve handling of 'empty' values for ChoiceField
The empty value defaults back to '' (for backwards-compatibility) but
is changed automatically to None for ModelSerializers if the `null`
property is set on the db field.
2013-11-05 17:21:18 +01:00
Rob Hudson
e33435d0da Fixed exception handling with YAML and XML parsers. 2013-10-31 15:03:50 -07:00
S. Andrew Sheppard
458af921f3 minor typo 2013-10-29 15:10:06 -05:00
Jakub Roztočil
be55a3c5c7 Removed commented-out credits from footer to make django-debug-toolbar work.
The comment, although valid, caused that the Django debug toolbar's injected HTML was partially commented-out and thus the toolbar didn't work as expected.
2013-10-24 17:53:02 +02:00
Chris Guethle
7a87893b96 reworked APIException, pushing some of the status_code and detail management up. Also, makes the APIException useful in isolation (defaults to status code 500) 2013-10-24 09:40:43 -05:00
Yamila Moreno
82e9ddcf7a Added get_filter_backends method 2013-10-24 16:16:01 +02:00
Tom Christie
0fc9d5fed9 Merge pull request #1198 from alexanderlukanin13/form-post-unicode
Fixed UnicodeEncodeError when POST JSON via web interface; added test
2013-10-24 05:45:55 -07:00
Tom Christie
6302307885 Update comment in get_parser_context. 2013-10-24 13:45:16 +01:00
alexanderlukanin13
6b3500b684 Fixed UnicodeEncodeError when POST JSON via web interface; added test 2013-10-24 17:52:52 +06:00
Tom Christie
f2648fefff Merge pull request #1187 from ross/paginator_def_val
paginator should validate page and provide default
2013-10-22 02:19:36 -07:00