Hallöchen!
Torsten Bronger writes:
> I use newforms.ModelForm to get a form from one of my models.
> However, the HTML <input> fields are all too wide. Okay, I could
> re-define all fields that need narrower <input>s like
>
> class SixChamberChannelForm(ModelForm):
> gas = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> diluted_in = forms.CharField(widget=forms.TextInput(attrs={"size": "10"}))
> class Meta:
> model = models.SixChamberChannel
>
> however, then I lose the information contained in max_length and
> help_text in the model. How can I just put a "size" attribute to
> the fields?
Okay, after some introspection (__dict__ rules) I found this
solution:
class SixChamberChannelForm(ModelForm):
def __init__(self, **keyw):
super(SixChamberLayerForm, self).__init__(**keyw)
self.fields["gas"].widget = forms.TextInput(attrs={"size": "10"})
self.fields["diluted_in"].widget = forms.TextInput(attrs={"size": "10"})
class Meta:
model = models.SixChamberChannel
I nobody sees possible unfortunate side effects here, I think that's
it.
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
Jabber ID: [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---