mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-04 23:44:07 +03:00
Latest docs build
This commit is contained in:
parent
2ec01f86f5
commit
0dd8a5ed41
|
@ -122,16 +122,18 @@
|
||||||
<h2 id="reverse">reverse</h2>
|
<h2 id="reverse">reverse</h2>
|
||||||
<p><strong>Signature:</strong> <code>reverse(viewname, request, *args, **kwargs)</code></p>
|
<p><strong>Signature:</strong> <code>reverse(viewname, request, *args, **kwargs)</code></p>
|
||||||
<p>Has the same behavior as <a href="https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse"><code>django.core.urlresolvers.reverse</code></a>, except that it returns a fully qualified URL, using the request to determine the host and port.</p>
|
<p>Has the same behavior as <a href="https://docs.djangoproject.com/en/dev/topics/http/urls/#reverse"><code>django.core.urlresolvers.reverse</code></a>, except that it returns a fully qualified URL, using the request to determine the host and port.</p>
|
||||||
<pre class="prettyprint lang-py"><code>from rest_framework.utils import reverse
|
<pre class="prettyprint lang-py"><code>import datetime
|
||||||
|
from rest_framework.utils import reverse
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
class MyView(APIView):
|
class APIRootView(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
content = {
|
year = datetime.datetime.now().year
|
||||||
|
data = {
|
||||||
...
|
...
|
||||||
'url': reverse('year-summary', request, args=[1945])
|
'year-summary-url': reverse('year-summary', request, args=[year])
|
||||||
}
|
}
|
||||||
return Response(content)
|
return Response(data)
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<h2 id="reverse_lazy">reverse_lazy</h2>
|
<h2 id="reverse_lazy">reverse_lazy</h2>
|
||||||
<p><strong>Signature:</strong> <code>reverse_lazy(viewname, request, *args, **kwargs)</code></p>
|
<p><strong>Signature:</strong> <code>reverse_lazy(viewname, request, *args, **kwargs)</code></p>
|
||||||
|
|
|
@ -94,11 +94,12 @@
|
||||||
<div class="span3">
|
<div class="span3">
|
||||||
<div id="table-of-contents" class="well affix span3">
|
<div id="table-of-contents" class="well affix span3">
|
||||||
<ul class="nav nav-list side-nav">
|
<ul class="nav nav-list side-nav">
|
||||||
<li class="main"><a href="#views">Views</a></li>
|
<li class="main"><a href="#class-based-views">Class Based Views</a></li>
|
||||||
<li><a href="#api-policy-attributes">API policy attributes</a></li>
|
<li><a href="#api-policy-attributes">API policy attributes</a></li>
|
||||||
<li><a href="#api-policy-instantiation-methods">API policy instantiation methods</a></li>
|
<li><a href="#api-policy-instantiation-methods">API policy instantiation methods</a></li>
|
||||||
<li><a href="#api-policy-implementation-methods">API policy implementation methods</a></li>
|
<li><a href="#api-policy-implementation-methods">API policy implementation methods</a></li>
|
||||||
<li><a href="#dispatch-methods">Dispatch methods</a></li>
|
<li><a href="#dispatch-methods">Dispatch methods</a></li>
|
||||||
|
<li class="main"><a href="#function-based-views">Function Based Views</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -106,7 +107,7 @@
|
||||||
|
|
||||||
<div id="main-content" class="span9">
|
<div id="main-content" class="span9">
|
||||||
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/decorators.py"><span class="label label-info">decorators.py</span></a> <a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/views.py"><span class="label label-info">views.py</span></a></p>
|
<p><a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/decorators.py"><span class="label label-info">decorators.py</span></a> <a class="github" href="https://github.com/tomchristie/django-rest-framework/blob/restframework2/rest_framework/views.py"><span class="label label-info">views.py</span></a></p>
|
||||||
<h1 id="views">Views</h1>
|
<h1 id="class-based-views">Class Based Views</h1>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<p>Django's class based views are a welcome departure from the old-style views.</p>
|
<p>Django's class based views are a welcome departure from the old-style views.</p>
|
||||||
<p>— <a href="http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html">Reinout van Rees</a></p>
|
<p>— <a href="http://reinout.vanrees.org/weblog/2011/08/24/class-based-views-usage.html">Reinout van Rees</a></p>
|
||||||
|
@ -177,6 +178,13 @@ This method is used to enforce permissions and throttling, and perform content n
|
||||||
<h3 id="finalize_responseself-request-response-args-kwargs">.finalize_response(self, request, response, <em>args, </em>*kwargs)</h3>
|
<h3 id="finalize_responseself-request-response-args-kwargs">.finalize_response(self, request, response, <em>args, </em>*kwargs)</h3>
|
||||||
<p>Ensures that any <code>Response</code> object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.</p>
|
<p>Ensures that any <code>Response</code> object returned from the handler method will be rendered into the correct content type, as determined by the content negotation.</p>
|
||||||
<p>You won't typically need to override this method.</p>
|
<p>You won't typically need to override this method.</p>
|
||||||
|
<h1 id="function-based-views">Function Based Views</h1>
|
||||||
|
<blockquote>
|
||||||
|
<p>Saying [that Class based views] is always the superior solution is a mistake.</p>
|
||||||
|
<p>— <a href="http://www.boredomandlaziness.org/2012/05/djangos-cbvs-are-not-mistake-but.html">Nick Coghlan</a></p>
|
||||||
|
</blockquote>
|
||||||
|
<p>REST framework also gives you to work with regular function based views...</p>
|
||||||
|
<p><strong>[TODO]</strong></p>
|
||||||
</div><!--/span-->
|
</div><!--/span-->
|
||||||
</div><!--/row-->
|
</div><!--/row-->
|
||||||
</div><!--/.fluid-container-->
|
</div><!--/.fluid-container-->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user