Version 3.8
-
Breaking Change: Alter
read_onlyplusdefaultbehaviour. #5886read_onlyfields will now always be excluded from writable fields.Previously
read_onlyfields with adefaultvalue would use thedefaultfor create and update operations.In order to maintain the old behaviour you may need to pass the value of
read_onlyfields when callingsave()in
the view:def perform_create(self, serializer): serializer.save(owner=self.request.user)Alternatively you may override
save()orcreate()orupdate()on the serialiser as appropriate. -
Correct allow_null behaviour when required=False #5888
Without an explicit
default,allow_nullimplies a default ofnullfor outgoing serialisation. Previously such
fields were being skipped when read-only or otherwise not required.Possible backwards compatibility break if you were relying on such fields being excluded from the outgoing
representation. In order to restore the old behaviour you can overridedatato exclude the field whenNone.For example:
@property def data(self): """ Drop `maybe_none` field if None. """ data = super().data() if 'maybe_none' in data and data['maybe_none'] is None: del data['maybe_none'] return data -
Refactor dynamic route generation and improve viewset action introspectibility. #5705
ViewSets have been provided with new attributes and methods that allow
it to introspect its set of actions and the details of the current action.- Merged
list_routeanddetail_routeinto a singleactiondecorator. - Get all extra actions on a
ViewSetwith.get_extra_actions(). - Extra actions now set the
url_nameandurl_pathon the decorated method. - Enable action url reversing through
.reverse_action()method (added in 3.7.4) - Example reverse call:
self.reverse_action(self.custom_action.url_name) - Add
detailinitkwarg to indicate if the current action is operating on a
collection or a single instance.
Additional changes:
- Deprecated
list_route&detail_routein favor ofactiondecorator withdetailboolean. - Deprecated dynamic list/detail route variants in favor of
DynamicRoutewithdetailboolean. - Refactored the router's dynamic route generation.
- Merged
-
Fix formatting of the 3.7.4 release note #5704
-
Docs: Update DRF Writable Nested Serializers references #5711
-
Docs: Fixed typo in auth URLs example. #5713
-
Improve composite field child errors #5655
-
Disable HTML inputs for dict/list fields #5702
-
Fix typo in HostNameVersioning doc #5709
-
Use rsplit to get module and classname for imports #5712
-
Formalize URLPatternsTestCase #5703
-
Add exception translation test #5700
-
Test staticfiles #5701
-
Add drf-yasg to documentation and schema 3rd party packages #5720
-
Remove unused
compat._resolve_model()#5733 -
Drop compat workaround for unsupported Python 3.2 #5734
-
Prefer
iter(dict)overiter(dict.keys())#5736 -
Pass
python_requiresargument to setuptools #5739 -
Remove unused links from docs #5735
-
Prefer https protocol for links in docs when available #5729
-
Add HStoreField, postgres fields tests #5654
-
Always fully qualify ValidationError in docs #5751
-
Remove unreachable code from ManualSchema #5766
-
Allowed customising API documentation code samples #5752
-
Updated docs to use
pip show#5757 -
Load 'static' instead of 'staticfiles' in templates #5773
-
Fixed a typo in
fieldsdocs #5783 -
Refer to "NamespaceVersioning" instead of "NamespacedVersioning" in the documentation #5754
-
ErrorDetail: add
__eq__/__ne__and__repr__#5787 -
Replace
background-attachment: fixedin docs #5777 -
Make 404 & 403 responses consistent with
exceptions.APIExceptionoutput #5763 -
Small fix to API documentation: schemas #5796
-
Fix schema generation for PrimaryKeyRelatedField #5764
-
Represent serializer DictField as an Object in schema #5765
-
Added docs example reimplementing ObtainAuthToken #5802
-
Add schema to the ObtainAuthToken view #5676
-
Fix request formdata handling #5800
-
Fix authtoken views imports #5818
-
Fixed active timezone handling for non ISO8601 datetimes. #5833
-
Made TemplateHTMLRenderer render IntegerField inputs when value is
0. #5834 -
Corrected endpoint in tutorial instructions #5835
-
Add Django Rest Framework Role Filters to Third party packages #5809
-
Use single copy of static assets. Update jQuery #5823
-
Changes ternary conditionals to be PEP308 compliant #5827
-
Added links to 'A Todo List API with React' and 'Blog API' tutorials #5837
-
Fix comment typo in ModelSerializer #5844
-
Add admin to installed apps to avoid test failures. #5870
-
Fixed schema for UUIDField in SimpleMetadata. #5872
-
Corrected docs on router include with namespaces. #5843
-
Test using model objects for dotted source default #5880
-
Allow traversing nullable related fields #5849
-
Added: Tutorial: Django REST with React (Django 2.0) #5891
-
Add
LimitOffsetPagination.get_countto allow method override #5846 -
Don't show hidden fields in metadata #5854
-
Enable OrderingFilter to handle an empty tuple (or list) for the 'ordering' field. #5899
-
Added generic 500 and 400 JSON error handlers. #5904