[2/4] compat: Add non-None queryset attribute

Submitted by Stephen Finucane on April 4, 2017, 9:38 p.m.

Details

Message ID 20170404213820.13350-2-stephen@that.guru
State New
Headers show

Commit Message

Stephen Finucane April 4, 2017, 9:38 p.m.
Older versions of Django REST Framework's 'RelatedField' did not check
for the presence 'get_queryset' before checking for a 'queryset'
attribute. This was fixed in 3.4.0 [1] and backported to the 3.3 series
in 3.3.3 [2]. However, the fix was not backported to the last release of
3.2 series [3], which is the last release to support Django 1.6. As
such, we must set a 'queryset' attribute, even if it's set to a garbage
value.

[1] ../blob/3.4.0/rest_framework/relations.py#L78-L82
[2] ../blob/3.3.3/rest_framework/relations.py#L78-L82
[3] ../blob/3.2.5/rest_framework/relations.py#L64-L67

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Daniel Axtens <dja@axtens.net>
Closes-bug: #94
---
 patchwork/api/patch.py | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py
index ded4910..fa6fb46 100644
--- a/patchwork/api/patch.py
+++ b/patchwork/api/patch.py
@@ -53,6 +53,7 @@  class StateField(RelatedField):
         'incorrect_type': _('Incorrect type. Expected string value, received '
                             '{data_type}.'),
     }
+    queryset = ''  # django 1.6, rest_framework 3.2 require this
 
     def to_internal_value(self, data):
         try: