Commit d12de927 by José Padilla

Remove docs for 3.0 banners

parent 2ddb6bfa
source: fields.py source: fields.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializer fields # Serializer fields
> Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format. > Each field in a Form class is responsible not only for validating data, but also for "cleaning" it — normalizing it to a consistent format.
......
source: mixins.py source: mixins.py
generics.py generics.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Generic views # Generic views
> Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself. > Django’s generic views... were developed as a shortcut for common usage patterns... They take certain common idioms and patterns found in view development and abstract them so that you can quickly write common views of data without having to repeat yourself.
......
source: metadata.py source: metadata.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Metadata # Metadata
> [The `OPTIONS`] method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. > [The `OPTIONS`] method allows a client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval.
...@@ -59,7 +53,7 @@ Or you can set the metadata class individually for a view: ...@@ -59,7 +53,7 @@ Or you can set the metadata class individually for a view:
class APIRoot(APIView): class APIRoot(APIView):
metadata_class = APIRootMetadata metadata_class = APIRootMetadata
def get(self, request, format=None): def get(self, request, format=None):
return Response({ return Response({
... ...
......
source: relations.py source: relations.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializer relations # Serializer relations
> Bad programmers worry about the code. > Bad programmers worry about the code.
......
source: request.py source: request.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Requests # Requests
> If you're doing REST-based web service stuff ... you should ignore request.POST. > If you're doing REST-based web service stuff ... you should ignore request.POST.
......
source: serializers.py source: serializers.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Serializers # Serializers
> Expanding the usefulness of the serializers is something that we would > Expanding the usefulness of the serializers is something that we would
...@@ -23,7 +17,7 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo ...@@ -23,7 +17,7 @@ The serializers in REST framework work very similarly to Django's `Form` and `Mo
Let's start by creating a simple object we can use for example purposes: Let's start by creating a simple object we can use for example purposes:
from datetime import datetime from datetime import datetime
class Comment(object): class Comment(object):
def __init__(self, email, content, created=None): def __init__(self, email, content, created=None):
self.email = email self.email = email
......
source: validators.py source: validators.py
---
**Note**: This is the documentation for the **version 3.0** of REST framework. Documentation for [version 2.4](http://tomchristie.github.io/rest-framework-2-docs/) is also available.
---
# Validators # Validators
> Validators can be useful for re-using validation logic between different types of fields. > Validators can be useful for re-using validation logic between different types of fields.
...@@ -33,7 +27,7 @@ When you're using `ModelSerializer` all of this is handled automatically for you ...@@ -33,7 +27,7 @@ When you're using `ModelSerializer` all of this is handled automatically for you
As an example of how REST framework uses explicit validation, we'll take a simple model class that has a field with a uniqueness constraint. As an example of how REST framework uses explicit validation, we'll take a simple model class that has a field with a uniqueness constraint.
class CustomerReportRecord(models.Model): class CustomerReportRecord(models.Model):
time_raised = models.DateTimeField(default=timezone.now, editable=False) time_raised = models.DateTimeField(default=timezone.now, editable=False)
reference = models.CharField(unique=True, max_length=20) reference = models.CharField(unique=True, max_length=20)
description = models.TextField() description = models.TextField()
...@@ -43,7 +37,7 @@ Here's a basic `ModelSerializer` that we can use for creating or updating instan ...@@ -43,7 +37,7 @@ Here's a basic `ModelSerializer` that we can use for creating or updating instan
class Meta: class Meta:
model = CustomerReportRecord model = CustomerReportRecord
If we open up the Django shell using `manage.py shell` we can now If we open up the Django shell using `manage.py shell` we can now
>>> from project.example.serializers import CustomerReportSerializer >>> from project.example.serializers import CustomerReportSerializer
>>> serializer = CustomerReportSerializer() >>> serializer = CustomerReportSerializer()
...@@ -204,7 +198,7 @@ A validator may be any callable that raises a `serializers.ValidationError` on f ...@@ -204,7 +198,7 @@ A validator may be any callable that raises a `serializers.ValidationError` on f
def even_number(value): def even_number(value):
if value % 2 != 0: if value % 2 != 0:
raise serializers.ValidationError('This field must be an even number.') raise serializers.ValidationError('This field must be an even number.')
## Class based ## Class based
...@@ -213,7 +207,7 @@ To write a class based validator, use the `__call__` method. Class based validat ...@@ -213,7 +207,7 @@ To write a class based validator, use the `__call__` method. Class based validat
class MultipleOf: class MultipleOf:
def __init__(self, base): def __init__(self, base):
self.base = base self.base = base
def __call__(self, value): def __call__(self, value):
if value % self.base != 0 if value % self.base != 0
message = 'This field must be a multiple of %d.' % self.base message = 'This field must be a multiple of %d.' % self.base
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment