aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--CHANGELOG.rst5
-rw-r--r--README.rst2
-rw-r--r--djangorestframework/compat.py2
-rw-r--r--djangorestframework/mixins.py3
-rw-r--r--djangorestframework/serializer.py13
-rw-r--r--djangorestframework/templatetags/add_query_param.py4
-rw-r--r--djangorestframework/tests/accept.py10
-rw-r--r--djangorestframework/views.py3
-rw-r--r--docs/howto/alternativeframeworks.rst2
-rwxr-xr-xsetup.py3
11 files changed, 40 insertions, 9 deletions
diff --git a/AUTHORS b/AUTHORS
index 47a31d05..2b042344 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -35,6 +35,8 @@ Sean C. Farley <scfarley>
Daniel Izquierdo <izquierdo>
Can Yavuz <tschan>
Shawn Lewis <shawnlewis>
+Adam Ness <greylurk>
+<yetist>
THANKS TO:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index ddc3ac17..6471edbe 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,11 @@
Release Notes
=============
+0.4.0-dev
+---------
+
+* Markdown < 2.0 is no longer supported.
+
0.3.3
-----
diff --git a/README.rst b/README.rst
index 23a8075e..d5fc0ce8 100644
--- a/README.rst
+++ b/README.rst
@@ -26,7 +26,7 @@ We also have a `Jenkins service <http://jenkins.tibold.nl/job/djangorestframewor
Requirements:
* Python (2.5, 2.6, 2.7 supported)
-* Django (1.2, 1.3, 1.4-alpha supported)
+* Django (1.2, 1.3, 1.4 supported)
Installation Notes
diff --git a/djangorestframework/compat.py b/djangorestframework/compat.py
index b8681022..0772e17b 100644
--- a/djangorestframework/compat.py
+++ b/djangorestframework/compat.py
@@ -399,6 +399,8 @@ else:
# Markdown is optional
try:
import markdown
+ if markdown.version_info < (2, 0):
+ raise ImportError('Markdown < 2.0 is not supported.')
class CustomSetextHeaderProcessor(markdown.blockprocessors.BlockProcessor):
"""
diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py
index 6c8f8179..0f292b4e 100644
--- a/djangorestframework/mixins.py
+++ b/djangorestframework/mixins.py
@@ -274,7 +274,8 @@ class ResponseMixin(object):
accept_list = [request.GET.get(self._ACCEPT_QUERY_PARAM)]
elif (self._IGNORE_IE_ACCEPT_HEADER and
'HTTP_USER_AGENT' in request.META and
- MSIE_USER_AGENT_REGEX.match(request.META['HTTP_USER_AGENT'])):
+ MSIE_USER_AGENT_REGEX.match(request.META['HTTP_USER_AGENT']) and
+ request.META.get('HTTP_X_REQUESTED_WITH', '') != 'XMLHttpRequest'):
# Ignore MSIE's broken accept behavior and do something sensible instead
accept_list = ['text/html', '*/*']
elif 'HTTP_ACCEPT' in request.META:
diff --git a/djangorestframework/serializer.py b/djangorestframework/serializer.py
index 5dea37e8..027c9daf 100644
--- a/djangorestframework/serializer.py
+++ b/djangorestframework/serializer.py
@@ -2,7 +2,7 @@
Customizable serialization.
"""
from django.db import models
-from django.db.models.query import QuerySet
+from django.db.models.query import QuerySet, RawQuerySet
from django.utils.encoding import smart_unicode, is_protected_type, smart_str
import inspect
@@ -179,7 +179,8 @@ class Serializer(object):
stack = self.stack[:]
stack.append(obj)
- return related_serializer(depth=depth, stack=stack).serialize(obj)
+ return related_serializer(depth=depth, stack=stack).serialize(
+ obj, request=getattr(self, 'request', None))
def serialize_max_depth(self, obj):
"""
@@ -253,15 +254,19 @@ class Serializer(object):
"""
return smart_unicode(obj, strings_only=True)
- def serialize(self, obj):
+ def serialize(self, obj, request=None):
"""
Convert any object into a serializable representation.
"""
+ # Request from related serializer.
+ if request is not None:
+ self.request = request
+
if isinstance(obj, (dict, models.Model)):
# Model instances & dictionaries
return self.serialize_model(obj)
- elif isinstance(obj, (tuple, list, set, QuerySet, types.GeneratorType)):
+ elif isinstance(obj, (tuple, list, set, QuerySet, RawQuerySet, types.GeneratorType)):
# basic iterables
return self.serialize_iter(obj)
elif isinstance(obj, models.Manager):
diff --git a/djangorestframework/templatetags/add_query_param.py b/djangorestframework/templatetags/add_query_param.py
index 4cf0133b..143d7b3f 100644
--- a/djangorestframework/templatetags/add_query_param.py
+++ b/djangorestframework/templatetags/add_query_param.py
@@ -4,7 +4,7 @@ register = Library()
def add_query_param(url, param):
- return unicode(URLObject(url).with_query(param))
+ return unicode(URLObject(url).add_query_param(*param.split('=')))
-register.filter('add_query_param', add_query_param)
+register.filter('add_query_param', add_query_param) \ No newline at end of file
diff --git a/djangorestframework/tests/accept.py b/djangorestframework/tests/accept.py
index 21aba589..7f4eb320 100644
--- a/djangorestframework/tests/accept.py
+++ b/djangorestframework/tests/accept.py
@@ -50,6 +50,16 @@ class UserAgentMungingTest(TestCase):
resp = self.view(req)
self.assertEqual(resp['Content-Type'], 'text/html')
+ def test_dont_munge_msie_with_x_requested_with_header(self):
+ """Send MSIE user agent strings, and an X-Requested-With header, and
+ ensure that we get a JSON response if we set a */* Accept header."""
+ for user_agent in (MSIE_9_USER_AGENT,
+ MSIE_8_USER_AGENT,
+ MSIE_7_USER_AGENT):
+ req = self.req.get('/', HTTP_ACCEPT='*/*', HTTP_USER_AGENT=user_agent, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
+ resp = self.view(req)
+ self.assertEqual(resp['Content-Type'], 'application/json')
+
def test_dont_rewrite_msie_accept_header(self):
"""Turn off _IGNORE_IE_ACCEPT_HEADER, send MSIE user agent strings and ensure
that we get a JSON response if we set a */* accept header."""
diff --git a/djangorestframework/views.py b/djangorestframework/views.py
index 3657fd64..4aa6ca0c 100644
--- a/djangorestframework/views.py
+++ b/djangorestframework/views.py
@@ -156,6 +156,9 @@ class View(ResourceMixin, RequestMixin, ResponseMixin, AuthMixin, DjangoView):
description = _remove_leading_indent(description)
+ if not isinstance(description, unicode):
+ description = description.decode('UTF-8')
+
if html:
return self.markup_description(description)
return description
diff --git a/docs/howto/alternativeframeworks.rst b/docs/howto/alternativeframeworks.rst
index dc8d1ea6..0f668335 100644
--- a/docs/howto/alternativeframeworks.rst
+++ b/docs/howto/alternativeframeworks.rst
@@ -7,7 +7,7 @@ Alternative frameworks
There are a number of alternative REST frameworks for Django:
* `django-piston <https://bitbucket.org/jespern/django-piston/wiki/Home>`_ is very mature, and has a large community behind it. This project was originally based on piston code in parts.
-* `django-tasypie <https://github.com/toastdriven/django-tastypie>`_ is also very good, and has a very active and helpful developer community and maintainers.
+* `django-tastypie <https://github.com/toastdriven/django-tastypie>`_ is also very good, and has a very active and helpful developer community and maintainers.
* Other interesting projects include `dagny <https://github.com/zacharyvoase/dagny>`_ and `dj-webmachine <http://benoitc.github.com/dj-webmachine/>`_
diff --git a/setup.py b/setup.py
index 5cd2a28f..79bd7353 100755
--- a/setup.py
+++ b/setup.py
@@ -64,6 +64,9 @@ setup(
package_data=get_package_data('djangorestframework'),
test_suite='djangorestframework.runtests.runcoverage.main',
install_requires=['URLObject>=0.6.0'],
+ extras_require={
+ 'markdown': ["Markdown>=2.0"]
+ },
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',