Skip to content

Commit 502499c

Browse files
committed
Fix 'rel.to' assignment for Django 1.9
1 parent feaf64c commit 502499c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fluent_pages/adminui/pageadmin.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import django
2+
13
native_str = str # no future.builtins.str, breaks default_change_form_template in Django 1.5, Python 2.7.5
24
from future.builtins import int
35
import copy
@@ -79,7 +81,10 @@ def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
7981
# It also partially fixes Django 1.3, which would wrongly point the url to ../../../fluent_pages/urlnode/ otherwise.
8082
if db_field.name == 'parent' and isinstance(field.widget, ForeignKeyRawIdWidget):
8183
field.widget.rel = copy.copy(field.widget.rel)
82-
field.widget.rel.to = Page
84+
if django.VERSION >= (1, 9):
85+
field.widget.rel.model = Page
86+
else:
87+
field.widget.rel.to = Page
8388

8489
return field
8590

0 commit comments

Comments
 (0)