@@ -676,7 +676,7 @@ def formfield(self, form_class=None, choices_form_class=None, **kwargs):
676
676
# we try to pass in. Very annoying because we have to
677
677
# un-encapsulate some of this initialization logic, this makes our
678
678
# EnumChoiceField pretty ugly!
679
- from django_enum .forms import EnumChoiceField , NonStrictSelect
679
+ from django_enum .forms import ChoiceFieldMixin , EnumChoiceField , NonStrictSelect
680
680
681
681
if not self .strict :
682
682
kwargs .setdefault ("widget" , NonStrictSelect )
@@ -687,10 +687,12 @@ def formfield(self, form_class=None, choices_form_class=None, **kwargs):
687
687
** kwargs ,
688
688
)
689
689
690
- # we can't pass these in kwargs because formfield() strips them out
691
- form_field .enum = self .enum
692
- form_field .strict = self .strict
693
- form_field .primitive = self .primitive
690
+ if isinstance (form_field , ChoiceFieldMixin ):
691
+ # we can't pass these in kwargs because formfield() strips them out
692
+ form_field .enum = self .enum
693
+ form_field .strict = self .strict
694
+ form_field .primitive = self .primitive
695
+ # pragma: no cover
694
696
return form_field
695
697
696
698
def get_choices (
@@ -1263,6 +1265,7 @@ def formfield(self, form_class=None, choices_form_class=None, **kwargs):
1263
1265
form_field .enum = self .enum
1264
1266
form_field .strict = self .strict
1265
1267
form_field .primitive = self .primitive
1268
+ # pragma: no cover
1266
1269
return form_field
1267
1270
1268
1271
def get_choices (
0 commit comments