mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-06 14:40:56 +03:00
Latest sponsor update
This commit is contained in:
parent
623304a19d
commit
66f25af53a
|
@ -255,6 +255,12 @@ class UserList(generics.ListCreateAPIView):
|
||||||
if self.request.accepted_renderer.format == 'html':
|
if self.request.accepted_renderer.format == 'html':
|
||||||
return 20
|
return 20
|
||||||
return 100
|
return 100
|
||||||
|
|
||||||
|
def list(self, request):
|
||||||
|
# Note the use of `get_queryset()` instead of `self.queryset`
|
||||||
|
queryset = self.get_queryset()
|
||||||
|
serializer = UserSerializer(queryset, many=True)
|
||||||
|
return Response(serializer.data)
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>For very simple cases you might want to pass through any class attributes using the <code>.as_view()</code> method. For example, your URLconf might include something the following entry.</p>
|
<p>For very simple cases you might want to pass through any class attributes using the <code>.as_view()</code> method. For example, your URLconf might include something the following entry.</p>
|
||||||
<pre class="prettyprint lang-py"><code>url(r'^/users/', ListCreateAPIView.as_view(model=User), name='user-list')
|
<pre class="prettyprint lang-py"><code>url(r'^/users/', ListCreateAPIView.as_view(model=User), name='user-list')
|
||||||
|
@ -268,7 +274,7 @@ class UserList(generics.ListCreateAPIView):
|
||||||
<p><strong>Basic settings</strong>:</p>
|
<p><strong>Basic settings</strong>:</p>
|
||||||
<p>The following attributes control the basic view behavior.</p>
|
<p>The following attributes control the basic view behavior.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><code>queryset</code> - The queryset that should be used for returning objects from this view. Typically, you must either set this attribute, or override the <code>get_queryset()</code> method.</li>
|
<li><code>queryset</code> - The queryset that should be used for returning objects from this view. Typically, you must either set this attribute, or override the <code>get_queryset()</code> method. If you are overriding a view method, it is important that you call <code>get_queryset()</code> instead of accessing this property directly, as <code>queryset</code> will get evaluated once, and those results will be cached for all subsequent requests.</li>
|
||||||
<li><code>serializer_class</code> - The serializer class that should be used for validating and deserializing input, and for serializing output. Typically, you must either set this attribute, or override the <code>get_serializer_class()</code> method.</li>
|
<li><code>serializer_class</code> - The serializer class that should be used for validating and deserializing input, and for serializing output. Typically, you must either set this attribute, or override the <code>get_serializer_class()</code> method.</li>
|
||||||
<li><code>lookup_field</code> - The model field that should be used to for performing object lookup of individual model instances. Defaults to <code>'pk'</code>. Note that when using hyperlinked APIs you'll need to ensure that <em>both</em> the API views <em>and</em> the serializer classes set the lookup fields if you need to use a custom value.</li>
|
<li><code>lookup_field</code> - The model field that should be used to for performing object lookup of individual model instances. Defaults to <code>'pk'</code>. Note that when using hyperlinked APIs you'll need to ensure that <em>both</em> the API views <em>and</em> the serializer classes set the lookup fields if you need to use a custom value.</li>
|
||||||
<li><code>lookup_url_kwarg</code> - The URL keyword argument that should be used for object lookup. The URL conf should include a keyword argument corresponding to this value. If unset this defaults to using the same value as <code>lookup_field</code>.</li>
|
<li><code>lookup_url_kwarg</code> - The URL keyword argument that should be used for object lookup. The URL conf should include a keyword argument corresponding to this value. If unset this defaults to using the same value as <code>lookup_field</code>.</li>
|
||||||
|
@ -293,6 +299,7 @@ class UserList(generics.ListCreateAPIView):
|
||||||
<p><strong>Base methods</strong>:</p>
|
<p><strong>Base methods</strong>:</p>
|
||||||
<h4 id="get_querysetself"><code>get_queryset(self)</code></h4>
|
<h4 id="get_querysetself"><code>get_queryset(self)</code></h4>
|
||||||
<p>Returns the queryset that should be used for list views, and that should be used as the base for lookups in detail views. Defaults to returning the queryset specified by the <code>queryset</code> attribute, or the default queryset for the model if the <code>model</code> shortcut is being used.</p>
|
<p>Returns the queryset that should be used for list views, and that should be used as the base for lookups in detail views. Defaults to returning the queryset specified by the <code>queryset</code> attribute, or the default queryset for the model if the <code>model</code> shortcut is being used.</p>
|
||||||
|
<p>This method should always be used rather than accessing <code>self.queryset</code> directly, as <code>self.queryset</code> gets evaluated only once, and those results are cached for all subsequent requests.</p>
|
||||||
<p>May be overridden to provide dynamic behavior such as returning a queryset that is specific to the user making the request.</p>
|
<p>May be overridden to provide dynamic behavior such as returning a queryset that is specific to the user making the request.</p>
|
||||||
<p>For example:</p>
|
<p>For example:</p>
|
||||||
<pre class="prettyprint lang-py"><code>def get_queryset(self):
|
<pre class="prettyprint lang-py"><code>def get_queryset(self):
|
||||||
|
|
BIN
img/1-kuwaitnet.png
Normal file
BIN
img/1-kuwaitnet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
img/labels-and-milestones.png
Normal file
BIN
img/labels-and-milestones.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
img/sponsors/2-pulsecode.png
Normal file
BIN
img/sponsors/2-pulsecode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
img/sponsors/2-singing-horse.png
Normal file
BIN
img/sponsors/2-singing-horse.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
336
topics/2.4-accouncement.html
Normal file
336
topics/2.4-accouncement.html
Normal file
|
@ -0,0 +1,336 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>REST framework 2.4 announcement - Django REST framework</title>
|
||||||
|
<link href="file:///Users/tomchristie/GitHub/django-rest-framework/html//img/favicon.ico" rel="icon" type="image/x-icon">
|
||||||
|
<link rel="canonical" href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/2.4-accouncement.html"/>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta name="description" content="Django, API, REST, REST framework 2.4 announcement">
|
||||||
|
<meta name="author" content="Tom Christie">
|
||||||
|
|
||||||
|
<!-- Le styles -->
|
||||||
|
<link href="file:///Users/tomchristie/GitHub/django-rest-framework/html//css/prettify.css" rel="stylesheet">
|
||||||
|
<link href="file:///Users/tomchristie/GitHub/django-rest-framework/html//css/bootstrap.css" rel="stylesheet">
|
||||||
|
<link href="file:///Users/tomchristie/GitHub/django-rest-framework/html//css/bootstrap-responsive.css" rel="stylesheet">
|
||||||
|
<link href="file:///Users/tomchristie/GitHub/django-rest-framework/html//css/default.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var _gaq = _gaq || [];
|
||||||
|
_gaq.push(['_setAccount', 'UA-18852272-2']);
|
||||||
|
_gaq.push(['_trackPageview']);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
|
})();
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
span.fusion-wrap a {
|
||||||
|
display: block;
|
||||||
|
margin-top: 10px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.fusion-poweredby {
|
||||||
|
display: block;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
div.promo {display: none;}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body onload="prettyPrint()" class="2.4-accouncement-page">
|
||||||
|
|
||||||
|
<div class="wrapper">
|
||||||
|
|
||||||
|
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="repo-link btn btn-primary btn-small" href="https://github.com/tomchristie/django-rest-framework/tree/master">GitHub</a>
|
||||||
|
<a class="repo-link btn btn-inverse btn-small disabled" href="#">Next <i class="icon-arrow-right icon-white"></i></a>
|
||||||
|
<a class="repo-link btn btn-inverse btn-small disabled" href="#"><i class="icon-arrow-left icon-white"></i> Previous</a>
|
||||||
|
<a class="repo-link btn btn-inverse btn-small" href="#searchModal" data-toggle="modal"><i class="icon-search icon-white"></i> Search</a>
|
||||||
|
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
<span class="icon-bar"></span>
|
||||||
|
</a>
|
||||||
|
<a class="brand" href="file:///Users/tomchristie/GitHub/django-rest-framework/html/index.html">Django REST framework</a>
|
||||||
|
<div class="nav-collapse collapse">
|
||||||
|
<ul class="nav">
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html/index.html">Home</a></li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tutorial <b class="caret"></b></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/quickstart.html">Quickstart</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/1-serialization.html">1 - Serialization</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/2-requests-and-responses.html">2 - Requests and responses</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/3-class-based-views.html">3 - Class based views</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/4-authentication-and-permissions.html">4 - Authentication and permissions</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/5-relationships-and-hyperlinked-apis.html">5 - Relationships and hyperlinked APIs</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//tutorial/6-viewsets-and-routers.html">6 - Viewsets and routers</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">API Guide <b class="caret"></b></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/requests.html">Requests</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/responses.html">Responses</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/views.html">Views</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/generic-views.html">Generic views</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/viewsets.html">Viewsets</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/routers.html">Routers</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/parsers.html">Parsers</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/renderers.html">Renderers</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/serializers.html">Serializers</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/fields.html">Serializer fields</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/relations.html">Serializer relations</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/authentication.html">Authentication</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/permissions.html">Permissions</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/throttling.html">Throttling</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/filtering.html">Filtering</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/pagination.html">Pagination</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/content-negotiation.html">Content negotiation</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/format-suffixes.html">Format suffixes</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/reverse.html">Returning URLs</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/exceptions.html">Exceptions</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/status-codes.html">Status codes</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/testing.html">Testing</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//api-guide/settings.html">Settings</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Topics <b class="caret"></b></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/documenting-your-api.html">Documenting your API</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/ajax-csrf-cors.html">AJAX, CSRF & CORS</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/browser-enhancements.html">Browser enhancements</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/browsable-api.html">The Browsable API</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/rest-hypermedia-hateoas.html">REST, Hypermedia & HATEOAS</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/contributing.html">Contributing to REST framework</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/rest-framework-2-announcement.html">2.0 Announcement</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/2.2-announcement.html">2.2 Announcement</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/2.3-announcement.html">2.3 Announcement</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/kickstarter-announcement.html">Kickstarter Announcement</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/release-notes.html">Release Notes</a></li>
|
||||||
|
<li><a href="file:///Users/tomchristie/GitHub/django-rest-framework/html//topics/credits.html">Credits</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<ul class="nav pull-right">
|
||||||
|
<!-- TODO
|
||||||
|
<li class="dropdown">
|
||||||
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Version: 2.0.0 <b class="caret"></b></a>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="#">Trunk</a></li>
|
||||||
|
<li><a href="#">2.0.0</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
-->
|
||||||
|
</ul>
|
||||||
|
</div><!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="body-content">
|
||||||
|
<div class="container-fluid">
|
||||||
|
|
||||||
|
<!-- Search Modal -->
|
||||||
|
<div id="searchModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3 id="myModalLabel">Documentation search</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- Custom google search -->
|
||||||
|
<script>
|
||||||
|
(function() {
|
||||||
|
var cx = '015016005043623903336:rxraeohqk6w';
|
||||||
|
var gcse = document.createElement('script');
|
||||||
|
gcse.type = 'text/javascript';
|
||||||
|
gcse.async = true;
|
||||||
|
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
|
||||||
|
'//www.google.com/cse/cse.js?cx=' + cx;
|
||||||
|
var s = document.getElementsByTagName('script')[0];
|
||||||
|
s.parentNode.insertBefore(gcse, s);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
<gcse:search></gcse:search>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row-fluid">
|
||||||
|
|
||||||
|
<div class="span3">
|
||||||
|
<!-- TODO
|
||||||
|
<p style="margin-top: -12px">
|
||||||
|
<a class="btn btn-mini btn-primary" style="width: 60px">« previous</a>
|
||||||
|
<a class="btn btn-mini btn-primary" style="float: right; margin-right: 8px; width: 60px;">next »</a>
|
||||||
|
</p>
|
||||||
|
-->
|
||||||
|
<div id="table-of-contents">
|
||||||
|
<ul class="nav nav-list side-nav well sidebar-nav-fixed">
|
||||||
|
<li class="main"><a href="#rest-framework-24-announcement">REST framework 2.4 announcement</a></li>
|
||||||
|
<li><a href="#version-requirements">Version requirements</a></li>
|
||||||
|
<li><a href="#django-17-support">Django 1.7 support</a></li>
|
||||||
|
<li><a href="#updated-test-runner">Updated test runner</a></li>
|
||||||
|
<li><a href="#improved-viewset-routing">Improved viewset routing</a></li>
|
||||||
|
<li><a href="#other-features">Other features</a></li>
|
||||||
|
<li><a href="#deprecations">Deprecations</a></li>
|
||||||
|
<li><a href="#labels-and-milestones">Labels and milestones</a></li>
|
||||||
|
<li><a href="#next-steps">Next steps</a></li>
|
||||||
|
|
||||||
|
<div class="promo">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="main-content" class="span9">
|
||||||
|
<h1 id="rest-framework-24-announcement">REST framework 2.4 announcement</h1>
|
||||||
|
<p>The 2.4 release is largely an intermediate step, tying up some outstanding issues prior to the 3.x series.</p>
|
||||||
|
<h2 id="version-requirements">Version requirements</h2>
|
||||||
|
<p>Support for Django 1.3 has been dropped.
|
||||||
|
The lowest supported version of Django is now 1.4.2.</p>
|
||||||
|
<p>The current plan is for REST framework to remain in lockstep with <a href="https://docs.djangoproject.com/en/dev/internals/release-process/#long-term-support-lts-releases">Django's long-term support policy</a>.</p>
|
||||||
|
<h2 id="django-17-support">Django 1.7 support</h2>
|
||||||
|
<p>The optional authtoken application now includes support for <em>both</em> Django 1.7 schema migrations, <em>and</em> for old-style <code>south</code> migrations.</p>
|
||||||
|
<p><strong>If you are using authtoken, and you want to continue using <code>south</code>, you must upgrade your <code>south</code> package to version 1.0.</strong></p>
|
||||||
|
<h2 id="updated-test-runner">Updated test runner</h2>
|
||||||
|
<p>We now have a new test runner for developing against the project,, that uses the excellent <a href="http://pytest.org">py.test</a> library.</p>
|
||||||
|
<p>To use it make sure you have first installed the test requirements.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>pip install -r requirements-test.txt
|
||||||
|
</code></pre>
|
||||||
|
<p>Then run the <code>runtests.py</code> script.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests.py
|
||||||
|
</code></pre>
|
||||||
|
<p>The new test runner also includes <a href="https://flake8.readthedocs.org">flake8</a> code linting, which should help keep our coding style consistent.</p>
|
||||||
|
<h4 id="test-runner-flags">Test runner flags</h4>
|
||||||
|
<p>Run using a more concise output style.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests -q
|
||||||
|
</code></pre>
|
||||||
|
<p>Run the tests using a more concise output style, no coverage, no flake8.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests --fast
|
||||||
|
</code></pre>
|
||||||
|
<p>Don't run the flake8 code linting.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests --nolint
|
||||||
|
</code></pre>
|
||||||
|
<p>Only run the flake8 code linting, don't run the tests.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests --lintonly
|
||||||
|
</code></pre>
|
||||||
|
<p>Run the tests for a given test case.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests MyTestCase
|
||||||
|
</code></pre>
|
||||||
|
<p>Run the tests for a given test method.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests MyTestCase.test_this_method
|
||||||
|
</code></pre>
|
||||||
|
<p>Shorter form to run the tests for a given test method.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>./runtests test_this_method
|
||||||
|
</code></pre>
|
||||||
|
<p>Note: The test case and test method matching is fuzzy and will sometimes run other tests that contain a partial string match to the given command line input.</p>
|
||||||
|
<h2 id="improved-viewset-routing">Improved viewset routing</h2>
|
||||||
|
<p>The <code>@action</code> and <code>@link</code> decorators were inflexible in that they only allowed additional routes to be added against instance style URLs, not against list style URLs.</p>
|
||||||
|
<p>The <code>@action</code> and <code>@link</code> decorators have now been moved to pending deprecation, and the <code>@list_route</code> and <code>@detail_route</code> decroators have been introduced.</p>
|
||||||
|
<p>Here's an example of using the new decorators. Firstly we have a detail-type route named "set_password" that acts on a single instance, and takes a <code>pk</code> argument in the URL. Secondly we have a list-type route named "recent_users" that acts on a queryset, and does not take any arguments in the URL.</p>
|
||||||
|
<pre class="prettyprint lang-py"><code>class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
A viewset that provides the standard actions
|
||||||
|
"""
|
||||||
|
queryset = User.objects.all()
|
||||||
|
serializer_class = UserSerializer
|
||||||
|
|
||||||
|
@detail_route(methods=['post'])
|
||||||
|
def set_password(self, request, pk=None):
|
||||||
|
user = self.get_object()
|
||||||
|
serializer = PasswordSerializer(data=request.DATA)
|
||||||
|
if serializer.is_valid():
|
||||||
|
user.set_password(serializer.data['password'])
|
||||||
|
user.save()
|
||||||
|
return Response({'status': 'password set'})
|
||||||
|
else:
|
||||||
|
return Response(serializer.errors,
|
||||||
|
status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
|
@list_route()
|
||||||
|
def recent_users(self, request):
|
||||||
|
recent_users = User.objects.all().order('-last_login')
|
||||||
|
page = self.paginate_queryset(recent_users)
|
||||||
|
serializer = self.get_pagination_serializer(page)
|
||||||
|
return Response(serializer.data)
|
||||||
|
</code></pre>
|
||||||
|
<p>For more details, see the <a href="../api-guide/viewsets.html">viewsets documentation</a>.</p>
|
||||||
|
<h2 id="other-features">Other features</h2>
|
||||||
|
<p>There are also a number of other features and bugfixes as <a href="./topics/release-notes/#240">listed in the release notes</a>. In particular these include:</p>
|
||||||
|
<p><a href="../api-guide/settings/#view-names-and-descriptions">Customizable view name and description functions</a> for use with the browsable API, by using the <code>VIEW_NAME_FUNCTION</code> and <code>VIEW_DESCRIPTION_FUNCTION</code> settings.</p>
|
||||||
|
<p>Smarter <a href="../api-guide/throttling/#how-clients-are-identified">client IP identification for throttling</a>, with the addition of the <code>NUM_PROXIES</code> setting.</p>
|
||||||
|
<h2 id="deprecations">Deprecations</h2>
|
||||||
|
<p>All API changes in 2.3 that previously raised <code>PendingDeprecationWarning</code> will now raise a <code>DeprecationWarning</code>, which is loud by default.</p>
|
||||||
|
<p>All API changes in 2.3 that previously raised <code>DeprecationWarning</code> have now been removed entirely.</p>
|
||||||
|
<p>Furter details on these deprecations is available in the <a href="./topics/2.3-announcement">2.3 announcement</a>.</p>
|
||||||
|
<h2 id="labels-and-milestones">Labels and milestones</h2>
|
||||||
|
<p>Although not strictly part of the 2.4 release it's also worth noting here that we've been working hard towards improving our triage process.</p>
|
||||||
|
<p>The <a href="https://github.com/tomchristie/django-rest-framework/issues">labels that we use in GitHub</a> have been cleaned up, and all existing tickets triaged. Any given ticket should have one and only one label, indicating its current state.</p>
|
||||||
|
<p>We've also <a href="https://github.com/tomchristie/django-rest-framework/milestones">started using milestones</a> in order to track tickets against particular releases.</p>
|
||||||
|
<hr />
|
||||||
|
<p><img alt="Labels and milestones" src="../img/labels-and-milestones.png" /></p>
|
||||||
|
<p><strong>Above</strong>: <em>Overview of our use of labels and milestones in GitHub.</em></p>
|
||||||
|
<hr />
|
||||||
|
<p>We hope both of these changes will help make the management process more clear and obvious and help keep tickets well-organised and relevant.</p>
|
||||||
|
<h2 id="next-steps">Next steps</h2>
|
||||||
|
<p>The next planned release will be 3.0, featuring an improved and simplified serializer implementation.</p>
|
||||||
|
<p>Once again, many thanks to all the generous <a href="./topics/kickstarter-announcement/#sponsors">backers and sponsors</a> who've helped make this possible!</p>
|
||||||
|
</div><!--/span-->
|
||||||
|
</div><!--/row-->
|
||||||
|
</div><!--/.fluid-container-->
|
||||||
|
</div><!--/.body content-->
|
||||||
|
|
||||||
|
<div id="push"></div>
|
||||||
|
</div><!--/.wrapper -->
|
||||||
|
|
||||||
|
<footer class="span12">
|
||||||
|
<p>Sponsored by <a href="http://dabapps.com/">DabApps</a>.</a></p>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
<!-- Le javascript
|
||||||
|
================================================== -->
|
||||||
|
<!-- Placed at the end of the document so the pages load faster -->
|
||||||
|
<script src="file:///Users/tomchristie/GitHub/django-rest-framework/html//js/jquery-1.8.1-min.js"></script>
|
||||||
|
<script src="file:///Users/tomchristie/GitHub/django-rest-framework/html//js/prettify-1.0.js"></script>
|
||||||
|
<script src="file:///Users/tomchristie/GitHub/django-rest-framework/html//js/bootstrap-2.1.1-min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
//$('.side-nav').scrollspy()
|
||||||
|
var shiftWindow = function() { scrollBy(0, -50) };
|
||||||
|
if (location.hash) shiftWindow();
|
||||||
|
window.addEventListener("hashchange", shiftWindow);
|
||||||
|
|
||||||
|
$('.dropdown-menu').on('click touchstart', function(event) {
|
||||||
|
event.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dynamically force sidenav to no higher than browser window
|
||||||
|
$('.side-nav').css('max-height', window.innerHeight - 130);
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
$(window).resize(function(){
|
||||||
|
$('.side-nav').css('max-height', window.innerHeight - 130);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body></html>
|
|
@ -244,6 +244,7 @@ a.fusion-poweredby {
|
||||||
<h3 id="blocks">Blocks</h3>
|
<h3 id="blocks">Blocks</h3>
|
||||||
<p>All of the blocks available in the browsable API base template that can be used in your <code>api.html</code>.</p>
|
<p>All of the blocks available in the browsable API base template that can be used in your <code>api.html</code>.</p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><code>body</code> - The entire html <code><body></code>.</li>
|
||||||
<li><code>bodyclass</code> - Class attribute for the <code><body></code> tag, empty by default.</li>
|
<li><code>bodyclass</code> - Class attribute for the <code><body></code> tag, empty by default.</li>
|
||||||
<li><code>bootstrap_theme</code> - CSS for the Bootstrap theme.</li>
|
<li><code>bootstrap_theme</code> - CSS for the Bootstrap theme.</li>
|
||||||
<li><code>bootstrap_navbar_variant</code> - CSS class for the navbar.</li>
|
<li><code>bootstrap_navbar_variant</code> - CSS class for the navbar.</li>
|
||||||
|
|
|
@ -261,6 +261,8 @@ a.fusion-poweredby {
|
||||||
<li><a href="http://lightningkite.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-lightning_kite.png);">Lightning Kite</a></li>
|
<li><a href="http://lightningkite.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-lightning_kite.png);">Lightning Kite</a></li>
|
||||||
<li><a href="https://opbeat.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-opbeat.png);">Opbeat</a></li>
|
<li><a href="https://opbeat.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-opbeat.png);">Opbeat</a></li>
|
||||||
<li><a href="https://koordinates.com" rel="nofollow" style="background-image:url(../img/sponsors/2-koordinates.png);">Koordinates</a></li>
|
<li><a href="https://koordinates.com" rel="nofollow" style="background-image:url(../img/sponsors/2-koordinates.png);">Koordinates</a></li>
|
||||||
|
<li><a href="http://pulsecode.ca" rel="nofollow" style="background-image:url(../img/sponsors/2-pulsecode.png);">Pulsecode Inc.</a></li>
|
||||||
|
<li><a href="http://singinghorsestudio.com" rel="nofollow" style="background-image:url(../img/sponsors/2-singing-horse.png);">Singing Horse Studio. Ltd.</a></li>
|
||||||
<li><a href="https://www.heroku.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-heroku.png);">Heroku</a></li>
|
<li><a href="https://www.heroku.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-heroku.png);">Heroku</a></li>
|
||||||
<li><a href="https://www.galileo-press.de/" rel="nofollow" style="background-image:url(../img/sponsors/2-galileo_press.png);">Galileo Press</a></li>
|
<li><a href="https://www.galileo-press.de/" rel="nofollow" style="background-image:url(../img/sponsors/2-galileo_press.png);">Galileo Press</a></li>
|
||||||
<li><a href="http://www.securitycompass.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-security_compass.png);">Security Compass</a></li>
|
<li><a href="http://www.securitycompass.com/" rel="nofollow" style="background-image:url(../img/sponsors/2-security_compass.png);">Security Compass</a></li>
|
||||||
|
@ -275,7 +277,7 @@ a.fusion-poweredby {
|
||||||
|
|
||||||
<div style="clear: both; padding-bottom: 40px;"></div>
|
<div style="clear: both; padding-bottom: 40px;"></div>
|
||||||
|
|
||||||
<p><strong>Individual backers</strong>: Xitij Ritesh Patel, Howard Sandford, Simon Haugk.</p>
|
<p><strong>Individual backers</strong>: Simon Haugk.</p>
|
||||||
<hr />
|
<hr />
|
||||||
<h3 id="silver-sponsors">Silver sponsors</h3>
|
<h3 id="silver-sponsors">Silver sponsors</h3>
|
||||||
<p>The serious financial contribution that our silver sponsors have made is very much appreciated. I'd like to say a particular thank you to individuals who have choosen to privately support the project at this level.</p>
|
<p>The serious financial contribution that our silver sponsors have made is very much appreciated. I'd like to say a particular thank you to individuals who have choosen to privately support the project at this level.</p>
|
||||||
|
|
|
@ -205,8 +205,8 @@ a.fusion-poweredby {
|
||||||
<p>We're going to create a simple API to allow admin users to view and edit the users and groups in the system.</p>
|
<p>We're going to create a simple API to allow admin users to view and edit the users and groups in the system.</p>
|
||||||
<h2 id="project-setup">Project setup</h2>
|
<h2 id="project-setup">Project setup</h2>
|
||||||
<p>Create a new Django project named <code>tutorial</code>, then start a new app called <code>quickstart</code>.</p>
|
<p>Create a new Django project named <code>tutorial</code>, then start a new app called <code>quickstart</code>.</p>
|
||||||
<pre class="prettyprint lang-py"><code># Set up a new project
|
<pre class="prettyprint lang-py"><code># Create the project directory
|
||||||
django-admin.py startproject tutorial
|
mkdir tutorial
|
||||||
cd tutorial
|
cd tutorial
|
||||||
|
|
||||||
# Create a virtualenv to isolate our package dependencies locally
|
# Create a virtualenv to isolate our package dependencies locally
|
||||||
|
@ -217,6 +217,9 @@ source env/bin/activate # On Windows use `env\Scripts\activate`
|
||||||
pip install django
|
pip install django
|
||||||
pip install djangorestframework
|
pip install djangorestframework
|
||||||
|
|
||||||
|
# Set up a new project
|
||||||
|
django-admin.py startproject tutorial
|
||||||
|
|
||||||
# Create a new app
|
# Create a new app
|
||||||
python manage.py startapp quickstart
|
python manage.py startapp quickstart
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user