On Sep 8, 7:55 pm, Kurczak <[EMAIL PROTECTED]> wrote: > On 8 Wrz, 20:37, David Zhou <[EMAIL PROTECTED]> wrote:> On Sep 8, 2008, at > 2:30 PM, Kurczak wrote: > > > > Is there any way to disable/remove the delete checkbox for inline > > > formsets ( in admin) ? > > > I found nothing about it in docs, and I believe there's no way to pass > > > the 'can_delete' parameter to inlineformset_factory. Obviously I can > > > disable the "Can delete" permission, but the ugly box is still there. > > > Have you tried editing the admin templates to not show the checkbox? > > Hi David, > thanks for your reply. > I just did in fact, but that affects every single inline form in the > project, and that's not what I want. There's no way to load inline > template (in admin) for selected app from what I learned. And I'd > rather not modify anything in django code because i don't really > consider that as solution. > Is there any other way? >
Well, it's not true that you can't change the inline template for a model - you can easily do so by using the 'template' attribute in the InlineModelAdmin class, see here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects However a better solution would probably be to define your own custom formset for the inline model, and set can_delete to false there. For example: from django.forms import models from django.contrib import admin class MyInline(models.BaseInlineFormset): def __init__(self, *args, **kwargs): super(MyInline, self).__init__(*args, **kwargs) self.can_delete = False class InlineOptions(admin.StackedInline): model = InlineModel formset = MyInline class MainOptions(admin.ModelAdmin): model = MainModel inlines = [InlineOptions] -- DR --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---