mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Fix django 1.3 bug
This commit is contained in:
parent
ae3340bcd4
commit
cc21948a69
|
@ -6,14 +6,30 @@
|
||||||
>
|
>
|
||||||
> — [The Zen of Python][cite]
|
> — [The Zen of Python][cite]
|
||||||
|
|
||||||
|
**Note:** The serializer fields are declared in fields.py, but by convention you should import them using `from rest_framework import serializers` and refer to fields as `serializers.<FieldName>`.
|
||||||
|
|
||||||
|
Serializer fields handle converting between primative values and internal datatypes. They also deal with validating input values, as well as retrieving and setting the values from their parent objects.
|
||||||
|
|
||||||
# Generic Fields
|
# Generic Fields
|
||||||
|
|
||||||
## Field
|
## Field
|
||||||
|
|
||||||
|
A generic, read-only field. You can use this field for any attribute that does not need to support write operations.
|
||||||
|
|
||||||
|
## WritableField
|
||||||
|
|
||||||
|
A field that supports both read and
|
||||||
|
|
||||||
## ModelField
|
## ModelField
|
||||||
|
|
||||||
|
A generic field that can be tied to any arbitrary model field. The `ModelField` class delegates the task of serialization/deserialization to it's associated model field. This field can be used to create serializer fields for custom model fields, without having to create a new custom serializer field.
|
||||||
|
|
||||||
|
**Signature:** `ModelField(model_field=<Django ModelField class>)`
|
||||||
|
|
||||||
# Typed Fields
|
# Typed Fields
|
||||||
|
|
||||||
|
These fields represent basic datatypes, and support both reading and writing values.
|
||||||
|
|
||||||
## BooleanField
|
## BooleanField
|
||||||
|
|
||||||
## CharField
|
## CharField
|
||||||
|
@ -30,7 +46,7 @@
|
||||||
|
|
||||||
# Relational Fields
|
# Relational Fields
|
||||||
|
|
||||||
Relational fields are used to represent model relationships.
|
Relational fields are used to represent model relationships. They can be applied to `ForeignKey`, `ManyToManyField` and `OneToOneField` relationships, as well as to reverse relationships, and custom relationships such as `GenericForeignKey`.
|
||||||
|
|
||||||
## PrimaryKeyRelatedField
|
## PrimaryKeyRelatedField
|
||||||
|
|
||||||
|
@ -40,4 +56,6 @@ Relational fields are used to represent model relationships.
|
||||||
|
|
||||||
## ManyHyperlinkedRelatedField
|
## ManyHyperlinkedRelatedField
|
||||||
|
|
||||||
|
## HyperLinkedIdentityField
|
||||||
|
|
||||||
[cite]: http://www.python.org/dev/peps/pep-0020/
|
[cite]: http://www.python.org/dev/peps/pep-0020/
|
||||||
|
|
|
@ -341,6 +341,7 @@ class HyperlinkedRelatedField(RelatedField):
|
||||||
|
|
||||||
def from_native(self, value):
|
def from_native(self, value):
|
||||||
# Convert URL -> model instance pk
|
# Convert URL -> model instance pk
|
||||||
|
# TODO: Use values_list
|
||||||
try:
|
try:
|
||||||
match = resolve(value)
|
match = resolve(value)
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -79,6 +79,8 @@ class SingleObjectBaseView(SingleObjectMixin, BaseView):
|
||||||
"""
|
"""
|
||||||
Base class for generic views onto a model instance.
|
Base class for generic views onto a model instance.
|
||||||
"""
|
"""
|
||||||
|
pk_url_kwarg = 'pk' # Not provided in Django 1.3
|
||||||
|
slug_url_kwarg = 'slug' # Not provided in Django 1.3
|
||||||
|
|
||||||
def get_object(self):
|
def get_object(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user