Deployed 6499378f with MkDocs version: 1.0.4

This commit is contained in:
Tom Christie 2019-07-15 12:41:00 +00:00
parent 799c472733
commit 16c6932394
4 changed files with 4 additions and 4 deletions

View File

@ -579,7 +579,7 @@ def create(self, validated_data):
<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>
<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>
<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>
<h4 id="change-to-validate_ltfield_namegt"><a class="toclink" href="#change-to-validate_ltfield_namegt">Change to <code>validate_&lt;field_name&gt;</code>.</a></h4>
<h4 id="change-to-validate_field_name"><a class="toclink" href="#change-to-validate_field_name">Change to <code>validate_&lt;field_name&gt;</code>.</a></h4>
<p>The <code>validate_&lt;field_name&gt;</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>
<pre><code>def validate_score(self, attrs, source):
if attrs['score'] % 10 != 0:
@ -605,7 +605,7 @@ def create(self, validated_data):
raise serializers.ValidationError({'my_field': 'A field error'})
</code></pre>
<p>This ensures you can still write validation that compares all the input fields, but that marks the error against a particular field.</p>
<h4 id="removal-of-transform_ltfield_namegt"><a class="toclink" href="#removal-of-transform_ltfield_namegt">Removal of <code>transform_&lt;field_name&gt;</code>.</a></h4>
<h4 id="removal-of-transform_field_name"><a class="toclink" href="#removal-of-transform_field_name">Removal of <code>transform_&lt;field_name&gt;</code>.</a></h4>
<p>The under-used <code>transform_&lt;field_name&gt;</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>
<p>For example:</p>
<pre><code>def to_representation(self, instance):

View File

@ -1320,7 +1320,7 @@ Previously may have been stored internally as <code>None</code>.</p>
<li>Added regex style to <code>SearchFilter</code>. (<a href="https://github.com/encode/django-rest-framework/issues/3316">#3316</a>)</li>
<li>Resolve issues with setting blank HTML fields. (<a href="https://github.com/encode/django-rest-framework/issues/3318">#3318</a>) (<a href="https://github.com/encode/django-rest-framework/issues/3321">#3321</a>)</li>
<li>Correctly display existing 'select multiple' values in browsable API forms. (<a href="https://github.com/encode/django-rest-framework/issues/3290">#3290</a>)</li>
<li>Resolve duplicated validation message for <code>IPAddressField</code>. ([#3249<a href="https://github.com/encode/django-rest-framework/issues/3249">gh3249</a>) (<a href="https://github.com/encode/django-rest-framework/issues/3250">#3250</a>)</li>
<li>Resolve duplicated validation message for <code>IPAddressField</code>. ([#3249[gh3249]) (<a href="https://github.com/encode/django-rest-framework/issues/3250">#3250</a>)</li>
<li>Fix to ensure admin renderer continues to work when pagination is disabled. (<a href="https://github.com/encode/django-rest-framework/issues/3275">#3275</a>)</li>
<li>Resolve error with <code>LimitOffsetPagination</code> when count=0, offset=0. (<a href="https://github.com/encode/django-rest-framework/issues/3303">#3303</a>)</li>
</ul>

File diff suppressed because one or more lines are too long

Binary file not shown.