eli
unread,Sep 5, 2009, 1:52:34 PM9/5/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi,
I have problem with Django Forms and field with set attrs to
disabled="disabled"
# forms.py
class EditForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(EditForm, self).__init__(*args, **kwargs)
self.fields['title'].widget.attrs.update({'readonly':
'readonly', 'disabled': 'disabled'})
class Meta:
model = MyModel
fields = ('title', 'tagline')
# views.py
form = EditForm(request.POST, instance=my_instance)
if form.is_valid():
form.save()
# models.py
class MyModel(models.Model):
title = models.CharField(max_length=120, db_index=True)
tagline = models.TextField(, max_length=500, db_index=True)
And now, Django remove values form field with attrs 'disabled':
'disabled' ("readonly" without "disabled" works fine, but I need
disabled option in my html output). Why Django do that?
Thanks for help.
regards.