So i'm trying to disable some form field widgets in an inline form (by setting disabled attribute in rendered html).
The following is a minified version of some code that seems to half work:
class IncomingItemForm(forms.ModelForm):
class Meta:
model = models.IncomingItem
def __init__(self, *args, **kwargs):
super(IncomingItemForm, self).__init__(*args, **kwargs)
if self.instance.id is not None:
self.fields[some_field_name].widget.attrs.update({'disabled' : 'disabled'})
class IncomingItemInline(admin.TabularInline):
model = models.IncomingItem
form = IncomingItemForm
What happens when i do this is: some_field_name is disabled for all but the first inline row.
I did some debugging by trying to disable only one row and it seems that this is an off-by-one error. Is this a django.contrib.admin bug or am i doing something stupid?
Edit: I'm using django 1.7b4