diff options
| author | Tom Christie | 2012-10-05 17:02:33 +0100 | 
|---|---|---|
| committer | Tom Christie | 2012-10-05 17:02:33 +0100 | 
| commit | cc21948a69f5cea90ca02042549af29c20e0268a (patch) | |
| tree | 3c40c6988adb90a488394ce3f6771876d9303c16 | |
| parent | ae3340bcd4cd8596459cf687c63ec2d8bf73fcd6 (diff) | |
| download | django-rest-framework-cc21948a69f5cea90ca02042549af29c20e0268a.tar.bz2 | |
Fix django 1.3 bug
| -rw-r--r-- | docs/api-guide/fields.md | 20 | ||||
| -rw-r--r-- | rest_framework/fields.py | 1 | ||||
| -rw-r--r-- | rest_framework/generics.py | 2 | 
3 files changed, 22 insertions, 1 deletions
diff --git a/docs/api-guide/fields.md b/docs/api-guide/fields.md index 009d2a79..5f3aba9a 100644 --- a/docs/api-guide/fields.md +++ b/docs/api-guide/fields.md @@ -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/ diff --git a/rest_framework/fields.py b/rest_framework/fields.py index cf7e692e..336eac1e 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -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: diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 44f677cc..51874f28 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -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):          """  | 
