Fix django 1.3 bug

This commit is contained in:
Tom Christie 2012-10-05 17:02:33 +01:00
parent ae3340bcd4
commit cc21948a69
3 changed files with 22 additions and 1 deletions

View File

@ -6,14 +6,30 @@
>
> — [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
## 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
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
These fields represent basic datatypes, and support both reading and writing values.
## BooleanField
## CharField
@ -30,7 +46,7 @@
# 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
@ -40,4 +56,6 @@ Relational fields are used to represent model relationships.
## ManyHyperlinkedRelatedField
## HyperLinkedIdentityField
[cite]: http://www.python.org/dev/peps/pep-0020/

View File

@ -341,6 +341,7 @@ class HyperlinkedRelatedField(RelatedField):
def from_native(self, value):
# Convert URL -> model instance pk
# TODO: Use values_list
try:
match = resolve(value)
except:

View File

@ -79,6 +79,8 @@ class SingleObjectBaseView(SingleObjectMixin, BaseView):
"""
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):
"""