You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The reason behind this is that Django's <code>ValidationError</code> class is intended for use with HTML forms and its API makes using it slightly awkward with nested validation errors that can occur in serializers.</p>
580
580
<p>For most users this change shouldn't require any updates to your codebase, but it is worth ensuring that whenever raising validation errors you should prefer using the <code>serializers.ValidationError</code> exception class, and not Django's built-in exception.</p>
581
581
<p>We strongly recommend that you use the namespaced import style of <code>import serializers</code> and not <code>from serializers import ValidationError</code> in order to avoid any potential confusion.</p>
582
-
<h4id="change-to-validate_field_name"><aclass="toclink" href="#change-to-validate_field_name">Change to <code>validate_<field_name></code>.</a></h4>
582
+
<h4id="change-to-validate_ltfield_namegt"><aclass="toclink" href="#change-to-validate_ltfield_namegt">Change to <code>validate_<field_name></code>.</a></h4>
583
583
<p>The <code>validate_<field_name></code> method hooks that can be attached to serializer classes change their signature slightly and return type. Previously these would take a dictionary of all incoming data, and a key representing the field name, and would return a dictionary including the validated data for that field:</p>
raise serializers.ValidationError({'my_field': 'A field error'})
606
606
</code></pre>
607
607
<p>This ensures you can still write validation that compares all the input fields, but that marks the error against a particular field.</p>
608
-
<h4id="removal-of-transform_field_name"><aclass="toclink" href="#removal-of-transform_field_name">Removal of <code>transform_<field_name></code>.</a></h4>
608
+
<h4id="removal-of-transform_ltfield_namegt"><aclass="toclink" href="#removal-of-transform_ltfield_namegt">Removal of <code>transform_<field_name></code>.</a></h4>
609
609
<p>The under-used <code>transform_<field_name></code> on serializer classes is no longer provided. Instead you should just override <code>to_representation()</code> if you need to apply any modifications to the representation style.</p>
<li>Added regex style to <code>SearchFilter</code>. (<ahref="https://github.com/encode/django-rest-framework/issues/3316">#3316</a>)</li>
1296
1299
<li>Resolve issues with setting blank HTML fields. (<ahref="https://github.com/encode/django-rest-framework/issues/3318">#3318</a>) (<ahref="https://github.com/encode/django-rest-framework/issues/3321">#3321</a>)</li>
1297
1300
<li>Correctly display existing 'select multiple' values in browsable API forms. (<ahref="https://github.com/encode/django-rest-framework/issues/3290">#3290</a>)</li>
1298
-
<li>Resolve duplicated validation message for <code>IPAddressField</code>. ([#3249[gh3249]) (<ahref="https://github.com/encode/django-rest-framework/issues/3250">#3250</a>)</li>
1301
+
<li>Resolve duplicated validation message for <code>IPAddressField</code>. ([#3249<ahref="https://github.com/encode/django-rest-framework/issues/3249">gh3249</a>) (<ahref="https://github.com/encode/django-rest-framework/issues/3250">#3250</a>)</li>
1299
1302
<li>Fix to ensure admin renderer continues to work when pagination is disabled. (<ahref="https://github.com/encode/django-rest-framework/issues/3275">#3275</a>)</li>
1300
1303
<li>Resolve error with <code>LimitOffsetPagination</code> when count=0, offset=0. (<ahref="https://github.com/encode/django-rest-framework/issues/3303">#3303</a>)</li>
0 commit comments