Drop support for Django 1.8
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import django
|
||||
from django.contrib.contenttypes.forms import BaseGenericInlineFormSet, generic_inlineformset_factory
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
@@ -32,12 +31,8 @@ class GenericPolymorphicFormSetChild(PolymorphicFormSetChild):
|
||||
opts = self.model._meta
|
||||
ct_field = opts.get_field(self.ct_field)
|
||||
|
||||
if django.VERSION >= (1, 9):
|
||||
if not isinstance(ct_field, models.ForeignKey) or ct_field.remote_field.model != ContentType:
|
||||
raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
|
||||
else:
|
||||
if not isinstance(ct_field, models.ForeignKey) or ct_field.rel.to != ContentType:
|
||||
raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
|
||||
if not isinstance(ct_field, models.ForeignKey) or ct_field.remote_field.model != ContentType:
|
||||
raise Exception("fk_name '%s' is not a ForeignKey to ContentType" % ct_field)
|
||||
|
||||
fk_field = opts.get_field(self.fk_field) # let the exception propagate
|
||||
exclude.extend([ct_field.name, fk_field.name])
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
|
||||
import django
|
||||
from django import forms
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ImproperlyConfigured, ValidationError
|
||||
@@ -226,10 +225,7 @@ class BasePolymorphicModelFormSet(BaseModelFormSet):
|
||||
"""
|
||||
forms = []
|
||||
for model, form_class in self.child_forms.items():
|
||||
if django.VERSION >= (1, 9):
|
||||
kwargs = self.get_form_kwargs(None) # New Django 1.9 method
|
||||
else:
|
||||
kwargs = {}
|
||||
kwargs = self.get_form_kwargs(None)
|
||||
|
||||
form = form_class(
|
||||
auto_id=self.auto_id,
|
||||
|
||||
Reference in New Issue
Block a user