Thanks Eric that did the job

On Jun 3, 1:50 pm, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> Yes, that was it. ModelForms are nice because you don't have to
> specify the fields to put in the form, it does that automatically.
> However, as soon as you want to customize the widgets being used for
> the fields, you _do_ have to specify the fields in yourModelForm, and
> put the classes and whatnot into the widget. So in your case, your
> form will have to do something like this:
>
> class Model_1Form(ModelForm):
>      title =
> forms.CharField(widget=forms.TextInput(attrs={'class':'super'}))
>      # other fields that need to be customized
>      class Meta:
>          model = Model_1
>          # etc
>
> That ought to do it...
>
> E
>
> On Jun 3, 2008, at 3:02 PM, Mayank Dhingra wrote:
>
>
>
> > Actually I wanted to know how to
>
> > Say I have a model "Model_1" and I made a form from that model using
> >ModelForm
> > now how am I supposed to addcustomCSSto the fields of this model?
>
> > class Model_1Form(ModelForm):
> >    class Meta:
> >        model = Model_1
> >        exclude = ('hash')
> >    def save(self, request):
> >      something something
>
> > Let me know if I missed something.
> > Thanks
>
> > On Jun 3, 9:14 am, Eric Abrahamsen <[EMAIL PROTECTED]> wrote:
> >> Hey there,
>
> >> You probably want 
> >> this:http://www.djangoproject.com/documentation/newforms/#customizing-widg
> >> ...
>
> >> You'll have to specify the field types for your model, then widget
> >> types for each field, and the extra attributes go in the widget.
>
> >> Yrs,
> >> E
>
> >> On Jun 3, 2008, at 2:23 AM, Mayank Dhingra wrote:
>
> >>> Hi,
>
> >>> I was looking to addcustomcssto the fields of a (new)form that I
> >>> created usingModelForm
> >>> but couldn't find any mention or discussion on it.
>
> >>> Does any know know how can I achieve it ?
>
> >>> Thanks in advance,
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to