From 96dc9ce1ad15275944a5fd9389843a30c6aff3c6 Mon Sep 17 00:00:00 2001 From: Otto Yiu Date: Wed, 31 Oct 2012 21:27:21 -0700 Subject: [PATCH 01/21] Fixing documentation on auth/throttling guides --- docs/api-guide/authentication.md | 6 +++--- docs/api-guide/throttling.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 889d16c03..3137b9d4c 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 bfda7079b..b03bc9e04 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', From 756297ad1d07f56459471bff041828850ace0496 Mon Sep 17 00:00:00 2001 From: Otto Yiu Date: Wed, 31 Oct 2012 21:40:20 -0700 Subject: [PATCH 02/21] fix 'from_native' method when rel is None 'NoneType' object has no attribute 'to' --- rest_framework/fields.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 1d6d760e3..73c8f72b9 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -211,9 +211,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) From 9a0cc7c720d40f7d2408672c49a5d8bfb62c3979 Mon Sep 17 00:00:00 2001 From: Pavel Savchenko Date: Thu, 1 Nov 2012 15:06:11 +0200 Subject: [PATCH 03/21] since MultipleObjectBaseView was renamed MultipleObjectAPIView, it stands to reason to complete the renaming in docs and comments as well. --- docs/tutorial/3-class-based-views.md | 4 ++-- rest_framework/mixins.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/3-class-based-views.md b/docs/tutorial/3-class-based-views.md index a31dccb2f..91ef40387 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/mixins.py b/rest_framework/mixins.py index 0f2a0d937..47e4edf72 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." From 600289a8153eb70542551bab00d59fb7ff0065f0 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 1 Nov 2012 13:31:22 +0000 Subject: [PATCH 04/21] Added @ottoyiu. Thanks! --- docs/topics/credits.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/topics/credits.md b/docs/topics/credits.md index a74f79838..df0223410 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 From d327c5f531b341ad980d20454211b02b87f34d0e Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 1 Nov 2012 23:04:13 +0000 Subject: [PATCH 05/21] Relational field support in browseable API. Add slug relational fields. Add quickstart. --- djangorestframework.egg-info/PKG-INFO | 19 ++++ djangorestframework.egg-info/SOURCES.txt | 86 ++++++++++++++ .../dependency_links.txt | 1 + djangorestframework.egg-info/top_level.txt | 7 ++ docs/index.md | 2 - docs/template.html | 2 +- docs/tutorial/quickstart.md | 9 +- rest_framework/fields.py | 107 +++++++++++++++++- rest_framework/renderers.py | 25 ++-- .../static/rest_framework/css/default.css | 7 ++ .../templates/rest_framework/base.html | 4 +- 11 files changed, 244 insertions(+), 25 deletions(-) create mode 100644 djangorestframework.egg-info/PKG-INFO create mode 100644 djangorestframework.egg-info/SOURCES.txt create mode 100644 djangorestframework.egg-info/dependency_links.txt create mode 100644 djangorestframework.egg-info/top_level.txt diff --git a/djangorestframework.egg-info/PKG-INFO b/djangorestframework.egg-info/PKG-INFO new file mode 100644 index 000000000..04eafbde9 --- /dev/null +++ b/djangorestframework.egg-info/PKG-INFO @@ -0,0 +1,19 @@ +Metadata-Version: 1.0 +Name: djangorestframework +Version: 2.0.0 +Summary: A lightweight REST framework for Django. +Home-page: http://django-rest-framework.org +Author: Tom Christie +Author-email: tom@tomchristie.com +License: BSD +Download-URL: http://pypi.python.org/pypi/rest_framework/ +Description: UNKNOWN +Platform: UNKNOWN +Classifier: Development Status :: 4 - Beta +Classifier: Environment :: Web Environment +Classifier: Framework :: Django +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: BSD License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python +Classifier: Topic :: Internet :: WWW/HTTP diff --git a/djangorestframework.egg-info/SOURCES.txt b/djangorestframework.egg-info/SOURCES.txt new file mode 100644 index 000000000..298d1c333 --- /dev/null +++ b/djangorestframework.egg-info/SOURCES.txt @@ -0,0 +1,86 @@ +MANIFEST.in +setup.py +djangorestframework.egg-info/PKG-INFO +djangorestframework.egg-info/SOURCES.txt +djangorestframework.egg-info/dependency_links.txt +djangorestframework.egg-info/top_level.txt +rest_framework/__init__.py +rest_framework/authentication.py +rest_framework/compat.py +rest_framework/decorators.py +rest_framework/exceptions.py +rest_framework/fields.py +rest_framework/generics.py +rest_framework/mixins.py +rest_framework/models.py +rest_framework/negotiation.py +rest_framework/pagination.py +rest_framework/parsers.py +rest_framework/permissions.py +rest_framework/renderers.py +rest_framework/request.py +rest_framework/response.py +rest_framework/reverse.py +rest_framework/serializers.py +rest_framework/settings.py +rest_framework/status.py +rest_framework/throttling.py +rest_framework/urlpatterns.py +rest_framework/urls.py +rest_framework/views.py +rest_framework/authtoken/__init__.py +rest_framework/authtoken/models.py +rest_framework/authtoken/views.py +rest_framework/authtoken/migrations/0001_initial.py +rest_framework/authtoken/migrations/__init__.py +rest_framework/runtests/__init__.py +rest_framework/runtests/runcoverage.py +rest_framework/runtests/runtests.py +rest_framework/runtests/settings.py +rest_framework/runtests/urls.py +rest_framework/static/rest_framework/css/bootstrap-tweaks.css +rest_framework/static/rest_framework/css/bootstrap.min.css +rest_framework/static/rest_framework/css/default.css +rest_framework/static/rest_framework/css/prettify.css +rest_framework/static/rest_framework/img/glyphicons-halflings-white.png +rest_framework/static/rest_framework/img/glyphicons-halflings.png +rest_framework/static/rest_framework/img/grid.png +rest_framework/static/rest_framework/js/bootstrap.min.js +rest_framework/static/rest_framework/js/default.js +rest_framework/static/rest_framework/js/jquery-1.8.1-min.js +rest_framework/static/rest_framework/js/prettify-min.js +rest_framework/templates/rest_framework/api.html +rest_framework/templates/rest_framework/base.html +rest_framework/templates/rest_framework/login.html +rest_framework/templatetags/__init__.py +rest_framework/templatetags/rest_framework.py +rest_framework/tests/__init__.py +rest_framework/tests/authentication.py +rest_framework/tests/breadcrumbs.py +rest_framework/tests/decorators.py +rest_framework/tests/description.py +rest_framework/tests/files.py +rest_framework/tests/genericrelations.py +rest_framework/tests/generics.py +rest_framework/tests/htmlrenderer.py +rest_framework/tests/hyperlinkedserializers.py +rest_framework/tests/models.py +rest_framework/tests/modelviews.py +rest_framework/tests/negotiation.py +rest_framework/tests/pagination.py +rest_framework/tests/parsers.py +rest_framework/tests/renderers.py +rest_framework/tests/request.py +rest_framework/tests/response.py +rest_framework/tests/reverse.py +rest_framework/tests/serializer.py +rest_framework/tests/status.py +rest_framework/tests/testcases.py +rest_framework/tests/tests.py +rest_framework/tests/throttling.py +rest_framework/tests/validators.py +rest_framework/tests/views.py +rest_framework/utils/__init__.py +rest_framework/utils/breadcrumbs.py +rest_framework/utils/encoders.py +rest_framework/utils/mediatypes.py \ No newline at end of file diff --git a/djangorestframework.egg-info/dependency_links.txt b/djangorestframework.egg-info/dependency_links.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/djangorestframework.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/djangorestframework.egg-info/top_level.txt b/djangorestframework.egg-info/top_level.txt new file mode 100644 index 000000000..7e18534d8 --- /dev/null +++ b/djangorestframework.egg-info/top_level.txt @@ -0,0 +1,7 @@ +rest_framework/authtoken +rest_framework/utils +rest_framework/tests +rest_framework/runtests +rest_framework/templatetags +rest_framework +rest_framework/authtoken/migrations diff --git a/docs/index.md b/docs/index.md index 75a1cf6e6..5e0868724 100644 --- a/docs/index.md +++ b/docs/index.md @@ -66,11 +66,9 @@ If you're intending to use the browseable API you'll want to add REST framework' Note that the URL path can be whatever you want, but you must include `rest_framework.urls` with the `rest_framework` namespace. - ## Tutorial diff --git a/docs/template.html b/docs/template.html index 94fc269f4..c428dff3a 100644 --- a/docs/template.html +++ b/docs/template.html @@ -53,7 +53,7 @@