Commit Graph

35 Commits

Author SHA1 Message Date
Jameel Al-Aziz
15c613a9eb
Allow generic requests, responses, fields, views (#8825)
Allow Request, Response, Field, and GenericAPIView to be subscriptable.
This allows the classes to be made generic for type checking.

This is especially useful since monkey patching DRF can be problematic
as seen in this [issue][1].

[1]: https://github.com/typeddjango/djangorestframework-stubs/issues/299
2023-02-22 21:39:01 +06:00
Klaas van Schelven
56946fac8f
Preserve exception messages for wrapped Django exceptions (#8051)
* Preserve messages for wrapped Django exceptions

* Fix the test

* Update test_generics.py

* Update test_generics.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2022-10-11 12:48:57 +00:00
Ryan P Kilby
e275b9036a
Allow context to be provided to get_serializer (#7298)
* Test generics serializer behavior

* Allow context to be provided to get_serializer
2020-04-29 11:19:44 +01:00
Jon Dufresne
513a49d63b Drop default 'utf-8' to .encode()/.decode() (#6633)
A Python 3 cleanup that allows for less noise in the code.

https://docs.python.org/3/library/stdtypes.html#bytes.decode
https://docs.python.org/3/library/stdtypes.html#str.encode
2019-05-01 07:49:16 +02:00
Carlton Gibson
0407a0df8a
Dropped Python 2 compatibility. (#6615)
Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com>
2019-04-30 17:53:44 +02:00
Nabil Jamaleddine
cdb8a3c3c8 Add ValidationError to except in get_object_or_404 for django 1.11 2017-05-05 21:17:12 -04:00
José Padilla
c1f31492ae
Update links after moving to encode org 2017-04-07 10:28:35 -04:00
Tom Christie
43b38964ea Support HEAD in viewsets 2017-03-13 12:51:03 +00:00
Artem Muterko
31e9f7dfbb Add remaining tests for generics (#4865) 2017-01-30 11:08:03 +00:00
Asif Saifuddin Auvi
10b5f36fec added fixes 2016-11-30 12:35:34 +06:00
Asif Saifuddin Auvi
f5a900a404 some reverts to fix test 2016-11-30 10:01:37 +06:00
Asif Saifuddin Auvi
a5bb9825f3 attempt to fix test again 2016-11-30 09:56:22 +06:00
Asif Saifuddin Auvi
4a0829d6ec attempt to fix test 2016-11-30 02:08:37 +06:00
Asif Saifuddin Auvi
27641e07b5 converted test asserts of generics-test to pytest 2016-11-30 01:13:21 +06:00
Tom Christie
9c996d7d2a Clean up existing deprecation warnings. (#4166)
* Add Meta.fields = '__all__' to serializer classes where required.
* Add explicit on_delete=models.CASCADE to ForeignKey fields.
* Use '.remote_field' and '.model' in preference to '.rel' and '.to' when inspecting model fields.
* Use new value_from_object in preference to internal _get_val_from_obj
2016-06-02 14:39:10 +01:00
Karambir Singh Nain
69f1e3a9fd Remove old django checks from tests and compat
Remove skipping of tests for Django<1.8. Remove several functions from compat.py not needed for Django>=1.8
2016-02-19 01:47:45 +05:30
Tom Christie
bdeb28944f Use RuntimeError, not AssertionError when guarding against direct View.queryset evalutation. Refs #3180. 2015-07-24 09:13:39 +01:00
Tom Christie
e05021c8c6 Guard against erronous direct .queryset evaluation in CBVs. 2015-07-23 17:17:18 +01:00
Tom Christie
d14bc3c4e1 Fix test cases for python3 2015-07-23 14:41:28 +01:00
Tom Christie
90fe0fb881 Errors in browsable API on error. Closes #3024. 2015-07-23 14:31:25 +01:00
José Padilla
7351a3f6ca Sort imports with isort 2015-06-25 16:55:51 -04:00
Tom Christie
2cc4cb2465 Fix error text in test. 2015-01-31 08:53:40 +00:00
Craig Blaszczyk
91e316f781 prefer single quotes in source and double quotes in user visible strings; add some missing full stops to user visible strings 2015-01-07 12:46:23 +00:00
Tymur Maryokhin
e2ea98e8ab Fixed typos 2014-11-29 20:23:55 +01:00
Tymur Maryokhin
dd9d40d8c0 Moved non-conflicting models 2014-11-29 20:04:50 +01:00
Tom Christie
2859eaf524 request.data attribute 2014-09-26 10:46:52 +01:00
Tom Christie
358445c174 Drop redundant OPTIONS tests 2014-09-24 14:52:34 +01:00
Tom Christie
250755def7 Clean up relational fields queryset usage 2014-09-12 10:59:51 +01:00
Tom Christie
de301f3b66 Merge master 2014-09-11 13:20:44 +01:00
Tom Christie
d934824bff Workin on 2014-09-05 16:29:46 +01:00
Tom Christie
f2852811f9 Getting tests passing 2014-09-02 17:41:23 +01:00
Tom Christie
b3253b4283 Remove .model usage in tests.
Remove the shortcut `.model` view attribute usage from test cases.
2014-08-29 12:35:53 +01:00
Tom Christie
63d02dbea8 Drop six from compat. 1.4.2 is now the lowest supported version. 2014-08-19 17:06:55 +01:00
Xavier Ordoquy
2489e38a06 Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
	.travis.yml
	docs/api-guide/viewsets.md
	rest_framework/serializers.py
	rest_framework/throttling.py
	tests/test_generics.py
	tests/test_serializers.py
	tox.ini
2014-06-23 14:02:45 +02:00
Andreas Pelme
971578ca34 Support for running the test suite with py.test
* Get rid of runtests.py
 * Moved test code  from rest_framework/tests and rest_framework/runtests to tests
 * Invoke py.test from setup.py
 * Invoke py.test from Travis
 * Invoke py.test from tox
 * Changed setUpClass to be just plain setUp in test_permissions.py
 * Updated contribution guideline to show how to invoke py.test
2014-03-02 12:40:30 +01:00