I've built this model which contains a generic foreign key:
class MyModel(models.Model): content_type = models.ForeignKey(ContentType, verbose_name=_('content type')) object_id = models.PositiveIntegerField(_('object id')) content_object = generic.GenericForeignKey('content_type', 'object_id')
Next I've made a generic stacked inline to put it in any ModelAmin class:
class MyModelStackedInline(generic.GenericStackedInline): model = MyModel formset = generic.generic_inlineformset_factory(MyModel, can_delete=False) extra = 0 class SomeOhterModelAdmin(admin.ModelAdmin): inlines = [MyModelStackedInline]
However, despite the can_delete=False
arg passed by in generic_inlineformset_factory, I always see a Delete
checkbox in my admin change_form.
Here is an example: http://img8.imageshack.us/img8/3323/screenshotbe.png
Do you know how to remove this checkbox ?
Thank you :)
Maybe It is a post '09 feature, but you can specify that without overriding the __init__()
method :
class StupidCarOptionsInline(admin.StackedInline): model = models.StupidOption form = StupidCarOptionAdminForm extra = 0 can_delete = False
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With