-
-
-
-
+{# Override this template in your own templates directory to customize #}
--
cgit v1.2.3
From f7fdcd55e451e4a37c518e1916dc2be513edbab5 Mon Sep 17 00:00:00 2001
From: Matt Majewski
Date: Wed, 17 Apr 2013 12:27:48 -0300
Subject: Update browsable-api.md
Add login template docs---
docs/topics/browsable-api.md | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/docs/topics/browsable-api.md b/docs/topics/browsable-api.md
index 5f80c4f9..8ee01824 100644
--- a/docs/topics/browsable-api.md
+++ b/docs/topics/browsable-api.md
@@ -60,6 +60,17 @@ All of the [Bootstrap components][bcomponents] are available.
The browsable API makes use of the Bootstrap tooltips component. Any element with the `js-tooltip` class and a `title` attribute has that title content displayed in a tooltip on hover after a 1000ms delay.
+### Login Template
+
+To add branding and customize the look-and-feel of the auth login template, create a template called `login.html` and add it to your project, eg: `templates/rest_framework/login.html`, that extends the `rest_framework/base_login.html` template.
+
+You can add your site name or branding by including the branding block:
+
+ {% block branding %}
+
My Site Name
+ {% endblock %}
+
+You can also customize the style by adding the `bootstrap_theme` or `style` block similar to `api.html`.
### Advanced Customization
--
cgit v1.2.3
From eb58596b89fcc083e5ad1d13b36006ae6ebbfafb Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Wed, 17 Apr 2013 23:17:08 +0200
Subject: Update release-notes.md
---
docs/topics/release-notes.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/docs/topics/release-notes.md b/docs/topics/release-notes.md
index 5e0aa098..106e7cd5 100644
--- a/docs/topics/release-notes.md
+++ b/docs/topics/release-notes.md
@@ -40,6 +40,10 @@ You can determine your currently installed version using `pip freeze`:
## 2.2.x series
+### Master
+
+* Made Login template more easy to restyle.
+
### 2.2.7
**Date**: 17th April 2013
--
cgit v1.2.3
From eaac15294080e9cda1610168262f9da2fd088e73 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Wed, 17 Apr 2013 23:19:16 +0200
Subject: Added @forgingdestiny for login template work.
Thanks! (Refs: #794)---
docs/topics/credits.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/docs/topics/credits.md b/docs/topics/credits.md
index da49e521..02e4dff8 100644
--- a/docs/topics/credits.md
+++ b/docs/topics/credits.md
@@ -116,6 +116,7 @@ The following people have helped make REST framework great.
* Victor Shih - [vshih]
* Atle Frenvik Sveen - [atlefren]
* J. Paul Reed - [preed]
+* Matt Majewski - [forgingdestiny]
Many thanks to everyone who's contributed to the project.
@@ -266,3 +267,5 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
[vshih]: https://github.com/vshih
[atlefren]: https://github.com/atlefren
[preed]: https://github.com/preed
+[forgingdestiny]: https://github.com/forgingdestiny
+
--
cgit v1.2.3
From 73019f91fe55f2ac16ce179917f686bf1a931597 Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Sat, 27 Apr 2013 14:29:32 +0200
Subject: Update docs on object-level permissions.
Closes #801.---
docs/api-guide/permissions.md | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md
index 4772c5e0..a7de77fc 100644
--- a/docs/api-guide/permissions.md
+++ b/docs/api-guide/permissions.md
@@ -21,7 +21,12 @@ If any permission check fails an `exceptions.PermissionDenied` exception will be
REST framework permissions also support object-level permissioning. Object level permissions are used to determine if a user should be allowed to act on a particular object, which will typically be a model instance.
-Object level permissions are run by REST framework's generic views when `.get_object()` is called. As with view level permissions, an `exceptions.PermissionDenied` exception will be raised if the user is not allowed to act on the given object.
+Object level permissions are run by REST framework's generic views when `.get_object()` is called.
+As with view level permissions, an `exceptions.PermissionDenied` exception will be raised if the user is not allowed to act on the given object.
+
+If you're writing your own views and want to enforce object level permissions,
+you'll need to explicitly call the `.check_object_permissions(request, obj)` method on the view at the point at which you've retrieved the object.
+This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or simply return if the view has the appropraite permissions.
## Setting the permission policy
--
cgit v1.2.3
From 33a26a76f1e8e1bde715711cca3acfd3992d07db Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Sat, 27 Apr 2013 16:35:42 +0200
Subject: Typo
---
docs/api-guide/permissions.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/api-guide/permissions.md b/docs/api-guide/permissions.md
index a7de77fc..0c82b2a3 100644
--- a/docs/api-guide/permissions.md
+++ b/docs/api-guide/permissions.md
@@ -26,7 +26,7 @@ As with view level permissions, an `exceptions.PermissionDenied` exception will
If you're writing your own views and want to enforce object level permissions,
you'll need to explicitly call the `.check_object_permissions(request, obj)` method on the view at the point at which you've retrieved the object.
-This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or simply return if the view has the appropraite permissions.
+This will either raise a `PermissionDenied` or `NotAuthenticated` exception, or simply return if the view has the appropriate permissions.
## Setting the permission policy
--
cgit v1.2.3
From 3b0fa3ebaa9d42723d970bb88be0dfe2586d1a5e Mon Sep 17 00:00:00 2001
From: JC
Date: Sat, 27 Apr 2013 13:10:39 -0700
Subject: Changed DepthTest to have depth=2
---
rest_framework/tests/serializer.py | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/rest_framework/tests/serializer.py b/rest_framework/tests/serializer.py
index 05217f35..bd874253 100644
--- a/rest_framework/tests/serializer.py
+++ b/rest_framework/tests/serializer.py
@@ -3,7 +3,7 @@ from django.utils.datastructures import MultiValueDict
from django.test import TestCase
from rest_framework import serializers
from rest_framework.tests.models import (HasPositiveIntegerAsChoice, Album, ActionItem, Anchor, BasicModel,
- BlankFieldModel, BlogPost, Book, CallableDefaultValueModel, DefaultValueModel,
+ BlankFieldModel, BlogPost, BlogPostComment, Book, CallableDefaultValueModel, DefaultValueModel,
ManyToManyModel, Person, ReadOnlyManyToManyModel, Photo)
import datetime
import pickle
@@ -767,8 +767,6 @@ class RelatedTraversalTest(TestCase):
post = BlogPost.objects.create(title="Test blog post", writer=user)
post.blogpostcomment_set.create(text="I love this blog post")
- from rest_framework.tests.models import BlogPostComment
-
class PersonSerializer(serializers.ModelSerializer):
class Meta:
model = Person
@@ -968,23 +966,26 @@ class SerializerPickleTests(TestCase):
class DepthTest(TestCase):
def test_implicit_nesting(self):
+
writer = Person.objects.create(name="django", age=1)
post = BlogPost.objects.create(title="Test blog post", writer=writer)
+ comment = BlogPostComment.objects.create(text="Test blog post comment", blog_post=post)
- class BlogPostSerializer(serializers.ModelSerializer):
+ class BlogPostCommentSerializer(serializers.ModelSerializer):
class Meta:
- model = BlogPost
- depth = 1
+ model = BlogPostComment
+ depth = 2
- serializer = BlogPostSerializer(instance=post)
- expected = {'id': 1, 'title': 'Test blog post',
- 'writer': {'id': 1, 'name': 'django', 'age': 1}}
+ serializer = BlogPostCommentSerializer(instance=comment)
+ expected = {'id': 1, 'text': 'Test blog post comment', 'blog_post': {'id': 1, 'title': 'Test blog post',
+ 'writer': {'id': 1, 'name': 'django', 'age': 1}}}
self.assertEqual(serializer.data, expected)
def test_explicit_nesting(self):
writer = Person.objects.create(name="django", age=1)
post = BlogPost.objects.create(title="Test blog post", writer=writer)
+ comment = BlogPostComment.objects.create(text="Test blog post comment", blog_post=post)
class PersonSerializer(serializers.ModelSerializer):
class Meta:
@@ -996,9 +997,15 @@ class DepthTest(TestCase):
class Meta:
model = BlogPost
- serializer = BlogPostSerializer(instance=post)
- expected = {'id': 1, 'title': 'Test blog post',
- 'writer': {'id': 1, 'name': 'django', 'age': 1}}
+ class BlogPostCommentSerializer(serializers.ModelSerializer):
+ blog_post = BlogPostSerializer()
+
+ class Meta:
+ model = BlogPostComment
+
+ serializer = BlogPostCommentSerializer(instance=comment)
+ expected = {'id': 1, 'text': 'Test blog post comment', 'blog_post': {'id': 1, 'title': 'Test blog post',
+ 'writer': {'id': 1, 'name': 'django', 'age': 1}}}
self.assertEqual(serializer.data, expected)
--
cgit v1.2.3
From 8cbb715f4c5550d76e397828608a31a4f254a37d Mon Sep 17 00:00:00 2001
From: JC
Date: Sat, 27 Apr 2013 13:23:55 -0700
Subject: Changed definition of NestedModelSerializer to correct depth handling
---
rest_framework/serializers.py | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index e28bbe81..add46566 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -205,18 +205,6 @@ class BaseSerializer(WritableField):
return ret
- #####
- # Field methods - used when the serializer class is itself used as a field.
-
- def initialize(self, parent, field_name):
- """
- Same behaviour as usual Field, except that we need to keep track
- of state so that we can deal with handling maximum depth.
- """
- super(BaseSerializer, self).initialize(parent, field_name)
- if parent.opts.depth:
- self.opts.depth = parent.opts.depth - 1
-
#####
# Methods to convert or revert from objects <--> primitive representations.
@@ -619,6 +607,8 @@ class ModelSerializer(Serializer):
class NestedModelSerializer(ModelSerializer):
class Meta:
model = model_field.rel.to
+ depth = self.opts.depth - 1
+
return NestedModelSerializer()
def get_related_field(self, model_field, to_many=False):
--
cgit v1.2.3
From 5d357a9b0807311b97de1e999be588f36fcd5b2f Mon Sep 17 00:00:00 2001
From: Tom Christie
Date: Mon, 29 Apr 2013 10:28:51 +0200
Subject: Added @chenjyw for depth bugfix #802. Thanks!
---
docs/topics/credits.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/docs/topics/credits.md b/docs/topics/credits.md
index 02e4dff8..7b8a428e 100644
--- a/docs/topics/credits.md
+++ b/docs/topics/credits.md
@@ -117,6 +117,7 @@ The following people have helped make REST framework great.
* Atle Frenvik Sveen - [atlefren]
* J. Paul Reed - [preed]
* Matt Majewski - [forgingdestiny]
+* Jerome Chen - [chenjyw]
Many thanks to everyone who's contributed to the project.
@@ -268,4 +269,4 @@ You can also contact [@_tomchristie][twitter] directly on twitter.
[atlefren]: https://github.com/atlefren
[preed]: https://github.com/preed
[forgingdestiny]: https://github.com/forgingdestiny
-
+[chenjyw]: https://github.com/chenjyw
--
cgit v1.2.3