Monday, April 9, 2012

Re: adding html5 field attributes to a model form

Hello Lee,

On Monday, April 9, 2012 6:14:08 PM UTC-7, Lee Hinde wrote:

I'm trying to edit the field type in a form that is using the html5 doctype. I've tried two ways:

Neither works. 

Am I looking in the wrong place?

I use both those techniques and they work great for me.  I've use them on many forms for a project I'm working on now.  Some examples from my code...

    brand_name = forms.CharField ( label = _( 'Brand Name' ), max_length = 128,
        widget = forms.TextInput ( attrs = { 'class' : 'span6', 'placeholder' :
        'enter brand name', } ) )

...and...

    def __init__ ( self, *args, **kwargs ):
   
        super ( AmountPerServing1Form, self ).__init__ ( *args, **kwargs )
       
        for key in self.fields:
       
            field = self.fields [ key ]
           
            field.widget.attrs [ 'class' ] = 'span7'

I don't see anything wrong with your syntax.  Have you tried the usual things?  Make sure you save the file your're editing, restart the server, etc?  And still the form didn't show up with your changes?

Could there be some browser or other caching going on between you and the server?

Are you sub-classing those forms for using them directly?

Toodle-looooooooooooo................
creecode

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/k6DJ30Z_ZWsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate