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
<li>The <code>FileUploadParser</code> is for usage with native clients that can upload the file as a raw data request. For web-based uploads, or for native clients with multipart upload support, you should use the <code>MultiPartParser</code>parser instead.</li>
574
+
<li>The <code>FileUploadParser</code> is for usage with native clients that can upload the file as a raw data request. For web-based uploads, or for native clients with multipart upload support, you should use the <code>MultiPartParser</code> instead.</li>
575
575
<li>Since this parser's <code>media_type</code> matches any content type, <code>FileUploadParser</code> should generally be the only parser set on an API view.</li>
576
576
<li><code>FileUploadParser</code> respects Django's standard <code>FILE_UPLOAD_HANDLERS</code> setting, and the <code>request.upload_handlers</code> attribute. See the <ahref="https://docs.djangoproject.com/en/stable/topics/http/file-uploads/#upload-handlers">Django documentation</a> for more details.</li>
<p><strong>Note:</strong> when you set new permission classes through class attribute or decorators you're telling the view to ignore the default list set over the <strong>settings.py</strong> file.</p>
593
593
<p>Provided they inherit from <code>rest_framework.permissions.BasePermission</code>, permissions can be composed using standard Python bitwise operators. For example, <code>IsAuthenticatedOrReadOnly</code> could be written:</p>
<p>The <ahref="https://github.com/niwibe/djangorestframework-composed-permissions">Composed Permissions</a> package provides a simple way to define complex and multi-depth (with logic operators) permission objects, using small and reusable components.</p>
<p>The <ahref="https://github.com/caxap/rest_condition">REST Condition</a> package is another extension for building complex permissions in a simple and convenient way. The extension allows you to combine permissions with logical operators.</p>
717
+
<p>The <ahref="https://github.com/caxap/rest_condition">REST Condition</a> package is another extension for building complex permissions in a simple and convenient way. The extension allows you to combine permissions with logical operators.</p>
<p>The <ahref="https://github.com/Helioscene/dry-rest-permissions">DRY Rest Permissions</a> package provides the ability to define different permissions for individual default and custom actions. This package is made for apps with permissions that are derived from relationships defined in the app's data model. It also supports permission checks being returned to a client app through the API's serializer. Additionally it supports adding permissions to the default and custom list actions to restrict the data they retrieve per user.</p>
<p>Relational fields are used to represent model relationships. They can be applied to <code>ForeignKey</code>, <code>ManyToManyField</code> and <code>OneToOneField</code> relationships, as well as to reverse relationships, and custom relationships such as <code>GenericForeignKey</code>.</p>
<p>To do so, open the Django shell, using <code>python manage.py shell</code>, then import the serializer class, instantiate it, and print the object representation…</p>
550
549
<pre><code>>>> from myapp.serializers import AccountSerializer
551
550
>>> serializer = AccountSerializer()
552
-
>>> print repr(serializer) # Or `print(repr(serializer))` in Python 3.x.
551
+
>>> print(repr(serializer))
553
552
AccountSerializer():
554
553
id = IntegerField(label='ID', read_only=True)
555
554
name = CharField(allow_blank=True, max_length=100, required=False)
<p>If you're building websites that use <code>TemplateHTMLRenderer</code> along with other renderer classes, you should consider listing <code>TemplateHTMLRenderer</code> as the first class in the <code>renderer_classes</code> list, so that it will be prioritised first even for browsers that send poorly formed <code>ACCEPT:</code> headers.</p>
662
662
<p>See the <ahref="../../topics/html-and-forms/"><em>HTML & Forms</em> Topic Page</a> for further examples of <code>TemplateHTMLRenderer</code> usage.</p>
<p>You can use <code>StaticHTMLRenderer</code> either to return regular HTML pages using REST framework, or to return both HTML and API responses from a single endpoint.</p>
<p>This renderer will determine which other renderer would have been given highest priority, and use that to display an API style response within the HTML page.</p>
<p>This renderer is used for rendering HTML multipart form data. <strong>It is not suitable as a response renderer</strong>, but is instead used for creating test requests, using REST framework's <ahref="../testing/">test client and test request factory</a>.</p>
<p>REST framework includes a few different renderers that you can use for
620
616
encoding the API schema.</p>
621
617
<ul>
622
-
<li><code>renderers.OpenAPIRenderer</code> - Renders into YAML-based [OpenAPI][openapi], the most widely used API schema format.</li>
623
-
<li><code>renderers.JSONOpenAPIRenderer</code> - Renders into JSON-based [OpenAPI][openapi].</li>
618
+
<li><code>renderers.OpenAPIRenderer</code> - Renders into YAML-based <ahref="https://openapis.org/">OpenAPI</a>, the most widely used API schema format.</li>
619
+
<li><code>renderers.JSONOpenAPIRenderer</code> - Renders into JSON-based <ahref="https://openapis.org/">OpenAPI</a>.</li>
624
620
<li><code>renderers.CoreJSONRenderer</code> - Renders into <ahref="https://www.coreapi.org/specification/encoding/#core-json-encoding">Core JSON</a>, a format designed for
625
621
use with the <code>coreapi</code> client library.</li>
<p>Note that the requests client requires you to pass fully qualified URLs.</p>
697
-
<h2id="requestsclient-and-working-with-the-database"><aclass="toclink" href="#requestsclient-and-working-with-the-database"><code>RequestsClient</code> and working with the database</a></h2>
697
+
<h2id="requestsclient-and-working-with-the-database"><aclass="toclink" href="#requestsclient-and-working-with-the-database">RequestsClient and working with the database</a></h2>
698
698
<p>The <code>RequestsClient</code> class is useful if you want to write tests that solely interact with the service interface. This is a little stricter than using the standard Django test client, as it means that all interactions should be via the API.</p>
699
699
<p>If you're using <code>RequestsClient</code> you'll want to ensure that test setup, and results assertions are performed as regular API calls, rather than interacting with the database models directly. For example, rather than checking that <code>Customer.objects.count() == 3</code> you would list the customers endpoint, and ensure that it contains three records.</p>
700
700
<h2id="headers-authentication"><aclass="toclink" href="#headers-authentication">Headers & Authentication</a></h2>
<p><strong>This release is incremental in nature. There <em>are</em> some breaking API changes, and upgrading <em>will</em> require you to read the release notes carefully, but the migration path should otherwise be relatively straightforward.</strong></p>
466
466
<p>The difference in quality of the REST framework API and implementation should make writing, maintaining and debugging your application far easier.</p>
467
467
<p>3.0 is the first of three releases that have been funded by our recent <ahref="https://www.kickstarter.com/projects/tomchristie/django-rest-framework-3">Kickstarter campaign</a>.</p>
468
-
<p>As ever, a huge thank you to our many <ahref="https://www.django-rest-framework.org/topics/kickstarter-announcement/#sponsors">wonderful sponsors</a>. If you're looking for a Django gig, and want to work with smart community-minded folks, you should probably check out that list and see who's hiring.</p>
468
+
<p>As ever, a huge thank you to our many <ahref="https://www.django-rest-framework.org/community/kickstarter-announcement/#sponsors">wonderful sponsors</a>. If you're looking for a Django gig, and want to work with smart community-minded folks, you should probably check out that list and see who's hiring.</p>
0 commit comments