Commit 399e4d9b by Tom Christie

Merge branch 'master' into logo

parents 3050f0e8 442916b9
...@@ -67,7 +67,7 @@ To run the tests, clone the repository, and then: ...@@ -67,7 +67,7 @@ To run the tests, clone the repository, and then:
# Run the tests # Run the tests
rest_framework/runtests/runtests.py rest_framework/runtests/runtests.py
You can also use the excellent `[tox][tox]` testing tool to run the tests against all supported versions of Python and Django. Install `tox` globally, and then simply run: You can also use the excellent [`tox`][tox] testing tool to run the tests against all supported versions of Python and Django. Install `tox` globally, and then simply run:
tox tox
......
...@@ -170,31 +170,12 @@ ...@@ -170,31 +170,12 @@
<ul class="nav nav-list side-nav well sidebar-nav-fixed"> <ul class="nav nav-list side-nav well sidebar-nav-fixed">
{{ toc }} {{ toc }}
<div> <div>
<hr>
<p><strong>The team behind REST framework is 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&amp;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>
{{ ad_block }}
</div>
</ul>
<!--End mc_embed_signup-->
</div> </div>
</div> </div>
......
...@@ -98,7 +98,7 @@ You can determine your currently installed version using `pip freeze`: ...@@ -98,7 +98,7 @@ You can determine your currently installed version using `pip freeze`:
class DisablePaginationMixin(object): class DisablePaginationMixin(object):
def get_paginate_by(self, queryset=None): def get_paginate_by(self, queryset=None):
if self.request.QUERY_PARAMS['self.paginate_by_param'] == '0': if self.request.QUERY_PARAMS[self.paginate_by_param] == '0':
return None return None
return super(DisablePaginationMixin, self).get_paginate_by(queryset) return super(DisablePaginationMixin, self).get_paginate_by(queryset)
......
...@@ -161,6 +161,12 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir): ...@@ -161,6 +161,12 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
output = output.replace('{{ page_id }}', filename[:-3]) output = output.replace('{{ page_id }}', filename[:-3])
output = output.replace('{{ canonical_url }}', canonical_url) output = output.replace('{{ canonical_url }}', canonical_url)
if filename =='index.md':
output = output.replace('{{ ad_block }}', """<hr><p><strong>The team behind REST framework is launching a new API service.</strong></p>
<p>If you want to be first in line when we start issuing invitations, please <a href="http://brightapi.com">sign up here</a>.</p>""")
else:
output = output.replace('{{ ad_block }}', '')
if prev_url: if prev_url:
output = output.replace('{{ prev_url }}', prev_url) output = output.replace('{{ prev_url }}', prev_url)
output = output.replace('{{ prev_url_disabled }}', '') output = output.replace('{{ prev_url_disabled }}', '')
......
...@@ -331,7 +331,7 @@ class BaseSerializer(WritableField): ...@@ -331,7 +331,7 @@ class BaseSerializer(WritableField):
return ret return ret
def from_native(self, data, files): def from_native(self, data, files=None):
""" """
Deserialize primitives -> objects. Deserialize primitives -> objects.
""" """
...@@ -894,7 +894,7 @@ class ModelSerializer(Serializer): ...@@ -894,7 +894,7 @@ class ModelSerializer(Serializer):
m2m_data[field_name] = attrs.pop(field_name) m2m_data[field_name] = attrs.pop(field_name)
# Forward m2m relations # Forward m2m relations
for field in meta.many_to_many: for field in meta.many_to_many + meta.virtual_fields:
if field.name in attrs: if field.name in attrs:
m2m_data[field.name] = attrs.pop(field.name) m2m_data[field.name] = attrs.pop(field.name)
......
...@@ -69,6 +69,35 @@ class TestGenericRelations(TestCase): ...@@ -69,6 +69,35 @@ class TestGenericRelations(TestCase):
} }
self.assertEqual(serializer.data, expected) self.assertEqual(serializer.data, expected)
def test_generic_nested_relation(self):
"""
Test saving a GenericRelation field via a nested serializer.
"""
class TagSerializer(serializers.ModelSerializer):
class Meta:
model = Tag
exclude = ('content_type', 'object_id')
class BookmarkSerializer(serializers.ModelSerializer):
tags = TagSerializer()
class Meta:
model = Bookmark
exclude = ('id',)
data = {
'url': 'https://docs.djangoproject.com/',
'tags': [
{'tag': 'contenttypes'},
{'tag': 'genericrelations'},
]
}
serializer = BookmarkSerializer(data=data)
self.assertTrue(serializer.is_valid())
serializer.save()
self.assertEqual(serializer.object.tags.count(), 2)
def test_generic_fk(self): def test_generic_fk(self):
""" """
Test a relationship that spans a GenericForeignKey field. Test a relationship that spans a GenericForeignKey field.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment