diff options
| author | Tom Christie | 2012-11-01 23:11:28 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-11-01 23:11:28 +0000 |
| commit | 36e21153fbc60579c49e46c3f6488ff7bcb1f6ff (patch) | |
| tree | 86097abd5482538c7c026dd233566026b6e6bcad | |
| parent | d327c5f531b341ad980d20454211b02b87f34d0e (diff) | |
| parent | 600289a8153eb70542551bab00d59fb7ff0065f0 (diff) | |
| download | django-rest-framework-36e21153fbc60579c49e46c3f6488ff7bcb1f6ff.tar.bz2 | |
Merge master
| -rw-r--r-- | docs/api-guide/authentication.md | 6 | ||||
| -rw-r--r-- | docs/api-guide/throttling.md | 6 | ||||
| -rw-r--r-- | docs/topics/credits.md | 2 | ||||
| -rw-r--r-- | docs/tutorial/3-class-based-views.md | 4 | ||||
| -rw-r--r-- | rest_framework/fields.py | 2 | ||||
| -rw-r--r-- | rest_framework/mixins.py | 2 | ||||
| -rw-r--r-- | rest_framework/renderers.py | 2 | ||||
| -rw-r--r-- | rest_framework/templates/rest_framework/base.html | 8 |
8 files changed, 17 insertions, 15 deletions
diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 889d16c0..3137b9d4 100644 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -30,7 +30,7 @@ The default authentication policy may be set globally, using the `DEFAULT_AUTHEN REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( - 'rest_framework.authentication.UserBasicAuthentication', + 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ) } @@ -38,7 +38,7 @@ The default authentication policy may be set globally, using the `DEFAULT_AUTHEN You can also set the authentication policy on a per-view basis, using the `APIView` class based views. class ExampleView(APIView): - authentication_classes = (SessionAuthentication, UserBasicAuthentication) + authentication_classes = (SessionAuthentication, BasicAuthentication) permission_classes = (IsAuthenticated,) def get(self, request, format=None): @@ -51,7 +51,7 @@ You can also set the authentication policy on a per-view basis, using the `APIVi Or, if you're using the `@api_view` decorator with function based views. @api_view(['GET']) - @authentication_classes((SessionAuthentication, UserBasicAuthentication)) + @authentication_classes((SessionAuthentication, BasicAuthentication)) @permissions_classes((IsAuthenticated,)) def example_view(request, format=None): content = { diff --git a/docs/api-guide/throttling.md b/docs/api-guide/throttling.md index bfda7079..b03bc9e0 100644 --- a/docs/api-guide/throttling.md +++ b/docs/api-guide/throttling.md @@ -31,8 +31,8 @@ The default throttling policy may be set globally, using the `DEFAULT_THROTTLE_C REST_FRAMEWORK = { 'DEFAULT_THROTTLE_CLASSES': ( - 'rest_framework.throttles.AnonThrottle', - 'rest_framework.throttles.UserThrottle' + 'rest_framework.throttling.AnonRateThrottle', + 'rest_framework.throttling.UserRateThrottle' ), 'DEFAULT_THROTTLE_RATES': { 'anon': '100/day', @@ -136,7 +136,7 @@ For example, given the following views... REST_FRAMEWORK = { 'DEFAULT_THROTTLE_CLASSES': ( - 'rest_framework.throttles.ScopedRateThrottle' + 'rest_framework.throttling.ScopedRateThrottle' ), 'DEFAULT_THROTTLE_RATES': { 'contacts': '1000/day', diff --git a/docs/topics/credits.md b/docs/topics/credits.md index a74f7983..df022341 100644 --- a/docs/topics/credits.md +++ b/docs/topics/credits.md @@ -52,6 +52,7 @@ The following people have helped make REST framework great. * Madis Väin - [madisvain] * Stephan Groß - [minddust] * Pavel Savchenko - [asfaltboy] +* Otto Yiu - [ottoyiu] Many thanks to everyone who's contributed to the project. @@ -139,3 +140,4 @@ To contact the author directly: [madisvain]: https://github.com/madisvain [minddust]: https://github.com/minddust [asfaltboy]: https://github.com/asfaltboy +[ottoyiu]: https://github.com/OttoYiu diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index a31dccb2..91ef4038 100644 --- a/docs/tutorial/3-class-based-views.md +++ b/docs/tutorial/3-class-based-views.md @@ -92,7 +92,7 @@ Let's take a look at how we can compose our views by using the mixin classes. class SnippetList(mixins.ListModelMixin, mixins.CreateModelMixin, - generics.MultipleObjectBaseView): + generics.MultipleObjectAPIView): model = Snippet serializer_class = SnippetSerializer @@ -102,7 +102,7 @@ Let's take a look at how we can compose our views by using the mixin classes. def post(self, request, *args, **kwargs): return self.create(request, *args, **kwargs) -We'll take a moment to examine exactly what's happening here - We're building our view using `MultipleObjectBaseView`, and adding in `ListModelMixin` and `CreateModelMixin`. +We'll take a moment to examine exactly what's happening here - We're building our view using `MultipleObjectAPIView`, and adding in `ListModelMixin` and `CreateModelMixin`. The base class provides the core functionality, and the mixin classes provide the `.list()` and `.create()` actions. We're then explicitly binding the `get` and `post` methods to the appropriate actions. Simple enough stuff so far. diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 6d858087..b7d02234 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -212,9 +212,9 @@ class ModelField(WritableField): def from_native(self, value): try: rel = self.model_field.rel + return rel.to._meta.get_field(rel.field_name).to_python(value) except: return self.model_field.to_python(value) - return rel.to._meta.get_field(rel.field_name).to_python(value) def field_to_native(self, obj, field_name): value = self.model_field._get_val_from_obj(obj) diff --git a/rest_framework/mixins.py b/rest_framework/mixins.py index 0f2a0d93..47e4edf7 100644 --- a/rest_framework/mixins.py +++ b/rest_framework/mixins.py @@ -29,7 +29,7 @@ class CreateModelMixin(object): class ListModelMixin(object): """ List a queryset. - Should be mixed in with `MultipleObjectBaseView`. + Should be mixed in with `MultipleObjectAPIView`. """ empty_error = u"Empty list and '%(class_name)s.allow_empty' is False." diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index 63578b14..73ae6edc 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -100,7 +100,7 @@ class JSONPRenderer(JSONRenderer): callback = self.get_callback(renderer_context) json = super(JSONPRenderer, self).render(data, accepted_media_type, renderer_context) - return "%s(%s);" % (callback, json) + return u"%s(%s);" % (callback, json) class XMLRenderer(BaseRenderer): diff --git a/rest_framework/templates/rest_framework/base.html b/rest_framework/templates/rest_framework/base.html index 9b0a0dca..fb0e19f0 100644 --- a/rest_framework/templates/rest_framework/base.html +++ b/rest_framework/templates/rest_framework/base.html @@ -131,12 +131,12 @@ {% csrf_token %} {{ post_form.non_field_errors }} {% for field in post_form %} - <div class="control-group {% if field.errors %}error{% endif %}"> + <div class="control-group"> <!--{% if field.errors %}error{% endif %}--> {{ field.label_tag|add_class:"control-label" }} <div class="controls"> {{ field }} <span class="help-inline">{{ field.help_text }}</span> - {{ field.errors|add_class:"help-block" }} + <!--{{ field.errors|add_class:"help-block" }}--> </div> </div> {% endfor %} @@ -156,12 +156,12 @@ {% csrf_token %} {{ put_form.non_field_errors }} {% for field in put_form %} - <div class="control-group {% if field.errors %}error{% endif %}"> + <div class="control-group"> <!--{% if field.errors %}error{% endif %}--> {{ field.label_tag|add_class:"control-label" }} <div class="controls"> {{ field }} <span class='help-inline'>{{ field.help_text }}</span> - {{ field.errors|add_class:"help-block" }} + <!--{{ field.errors|add_class:"help-block" }}--> </div> </div> {% endfor %} |
