diff options
| -rw-r--r-- | docs/api-guide/exceptions.md | 2 | ||||
| -rwxr-xr-x | docs/api-guide/generic-views.md | 3 | ||||
| -rw-r--r-- | docs/template.html | 25 | ||||
| -rw-r--r-- | rest_framework/generics.py | 5 | ||||
| -rw-r--r-- | rest_framework/mixins.py | 3 | 
5 files changed, 34 insertions, 4 deletions
diff --git a/docs/api-guide/exceptions.md b/docs/api-guide/exceptions.md index 0c48783a..c46d415e 100644 --- a/docs/api-guide/exceptions.md +++ b/docs/api-guide/exceptions.md @@ -82,7 +82,7 @@ Note that the exception handler will only be called for responses generated by r  ## APIException -**Signature:** `APIException(detail=None)` +**Signature:** `APIException()`  The **base class** for all exceptions raised inside REST framework. diff --git a/docs/api-guide/generic-views.md b/docs/api-guide/generic-views.md index dc0076df..24fc0bc7 100755 --- a/docs/api-guide/generic-views.md +++ b/docs/api-guide/generic-views.md @@ -65,7 +65,8 @@ The following attributes control the basic view behavior.  * `queryset` - The queryset that should be used for returning objects from this view.  Typically, you must either set this attribute, or override the `get_queryset()` method.  * `serializer_class` - 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 `get_serializer_class()` method. -* `lookup_field` - The field that should be used to lookup individual model instances.  Defaults to `'pk'`.  The URL conf should include a keyword argument corresponding to this value.  More complex lookup styles can be supported by overriding the `get_object()` method.  Note that when using hyperlinked APIs you'll need to ensure that *both* the API views *and* the serializer classes use lookup fields that correctly correspond with the URL conf. +* `lookup_field` - The model field that should be used to for performing object lookup of individual model instances.  Defaults to `'pk'`.  Note that when using hyperlinked APIs you'll need to ensure that *both* the API views *and* the serializer classes set the lookup fields if you need to use a custom value. +* `lookup_url_kwarg` - 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 `lookup_field`.  **Shortcuts**: diff --git a/docs/template.html b/docs/template.html index a20c8111..749d0afe 100644 --- a/docs/template.html +++ b/docs/template.html @@ -167,7 +167,32 @@              <div id="table-of-contents">                <ul class="nav nav-list side-nav well sidebar-nav-fixed">                  {{ toc }} +              <div> +              <hr> + +<p><strong>The team behind REST framework are launching a new API service.</strong></p> + +<p>If you want to be first in line when we start issuing invitations, please sign up here:</p> + +<!-- Begin MailChimp Signup Form --> +<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css"> +<style type="text/css"> +    #mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; } +    /* Add your own MailChimp form style overrides in your site stylesheet or in this style block. +       We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */ +</style> +<div id="mc_embed_signup" style="background: rgb(245, 245, 245)"> +<form action="http://dabapps.us1.list-manage1.com/subscribe/post?u=cf73a9994eb5b8d8d461b5dfb&id=cb6af8e8bd" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> +<!--     <label for="mce-EMAIL">Keep me posted!</label> + -->    <input style="width: 90%" type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required> +    <div class="clear"><input class="btn btn-success" type="submit" value="Yes, keep me posted!" name="subscribe" id="mc-embedded-subscribe" class="button"></div> +</form> +</div> +</style></div>                </ul> + + +<!--End mc_embed_signup-->              </div>            </div> diff --git a/rest_framework/generics.py b/rest_framework/generics.py index 4015ab20..6d204cf5 100644 --- a/rest_framework/generics.py +++ b/rest_framework/generics.py @@ -54,6 +54,7 @@ class GenericAPIView(views.APIView):      # If you want to use object lookups other than pk, set this attribute.      # For more complex lookup requirements override `get_object()`.      lookup_field = 'pk' +    lookup_url_kwarg = None      # Pagination settings      paginate_by = api_settings.PAGINATE_BY @@ -278,9 +279,11 @@ class GenericAPIView(views.APIView):              pass  # Deprecation warning          # Perform the lookup filtering. +        # Note that `pk` and `slug` are deprecated styles of lookup filtering. +        lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field +        lookup = self.kwargs.get(lookup_url_kwarg, None)          pk = self.kwargs.get(self.pk_url_kwarg, None)          slug = self.kwargs.get(self.slug_url_kwarg, None) -        lookup = self.kwargs.get(self.lookup_field, None)          if lookup is not None:              filter_kwargs = {self.lookup_field: lookup} diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 426865ff..4606c78b 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -158,7 +158,8 @@ class UpdateModelMixin(object):          Set any attributes on the object that are implicit in the request.          """          # pk and/or slug attributes are implicit in the URL. -        lookup = self.kwargs.get(self.lookup_field, None) +        lookup_url_kwarg = self.lookup_url_kwarg or self.lookup_field +        lookup = self.kwargs.get(lookup_url_kwarg, None)          pk = self.kwargs.get(self.pk_url_kwarg, None)          slug = self.kwargs.get(self.slug_url_kwarg, None)          slug_field = slug and self.slug_field or None  | 
