You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Haven't been able to dig through Admin to find out how to apply the same kind of patching to inline objects as is done in the included ModelAdmin subclass.
If anyone has any pointers would be happy to try further.
The text was updated successfully, but these errors were encountered:
classTabularInlineTypedModel(admin.TabularInline):
"""Mixin copied typedmodels.admin.TypedModelAdmin"""defget_fields(self, request, obj=None):
fields=super().get_fields(request, obj)
# we remove the type field from the admin of subclasses.ifTypedModelnotinself.model.__bases__:
fields.remove(self.model._meta.get_field("type").name)
returnfieldsdefsave_model(self, request, obj, form, change):
ifgetattr(obj, "_typedmodels_type", None) isNone:
# new instances don't have the type attributeobj._typedmodels_type=form.cleaned_data["type"]
obj.save()
classStackedInlineTypedModel(admin.StackedInline):
"""Mixin copied typedmodels.admin.TypedModelAdmin"""defget_fields(self, request, obj=None):
fields=super().get_fields(request, obj)
# we remove the type field from the admin of subclasses.ifTypedModelnotinself.model.__bases__:
fields.remove(self.model._meta.get_field("type").name)
returnfieldsdefsave_model(self, request, obj, form, change):
ifgetattr(obj, "_typedmodels_type", None) isNone:
# new instances don't have the type attributeobj._typedmodels_type=form.cleaned_data["type"]
obj.save()
Haven't been able to dig through Admin to find out how to apply the same kind of patching to inline objects as is done in the included ModelAdmin subclass.
If anyone has any pointers would be happy to try further.
The text was updated successfully, but these errors were encountered: