bootstrap django crispy forms

69 views
Skip to first unread message

clarkso...@gmail.com

unread,
Feb 26, 2016, 10:39:09 AM2/26/16
to Django users

A simple upload button is proving difficult to implement bootstrap and css on.... My attempt is as follows:

     class DocumentForm(forms.Form):
       docfile = forms.FileField(label='Choose')
       def __init__(self, *args, **kwargs): # don't particularly know or care about this and the below component....
         super(DocumentForm, self).__init__(*args, **kwargs) #but they are necessary to not get an error
         ButtonHolder(
           Div('docfile', style="background: black;", css_class="col-md-12", css_id="burton", template='home.html')
           ), #the Div part is what I'm most interested in- in order to be able to style the button.

Furthermore, having set the "css_class" to "burton", I have tried referencing it in a normal css file:

     .burton{
        ....
      }

but that too is obviously misguided??

Can someone tell me where I'm going wrong?

Mike Dewhirst

unread,
Feb 26, 2016, 5:39:58 PM2/26/16
to django...@googlegroups.com
This is probably wrong for your case but occasionally I have had success
overriding (or is that cascading?) style sheets by adding "!important"
to the pertinent item in my .css file.

On 27/02/2016 2:39 AM, clarkso...@gmail.com wrote:
> A simple upload button is proving difficult to implement bootstrap and
> css on.... My attempt is as follows:
>
> |classDocumentForm(forms.Form):docfile
> =forms.FileField(label='Choose')def__init__(self,*args,**kwargs): #
> don't particularly know or care about this and the below
> component....super(DocumentForm,self).__init__(*args,**kwargs) #but they
> are necessary to not get an
> errorButtonHolder(Div('docfile',style="background:
> black;",css_class="col-md-12",css_id="burton",template='home.html')),
> #the Div part is what I'm most interested in- in order to be able to
> style the button.|
>
> Furthermore, having set the "css_class" to "burton", I have tried
> referencing it in a normal css file:
>
> |.burton{....}|
>
> but that too is obviously misguided??
>
> Can someone tell me where I'm going wrong?
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To post to this group, send email to django...@googlegroups.com
> <mailto:django...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a3380d61-8348-4904-8f8b-83d5fdeab070%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a3380d61-8348-4904-8f8b-83d5fdeab070%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

James Schneider

unread,
Feb 29, 2016, 7:39:24 PM2/29/16
to django...@googlegroups.com
I answered your other email that had a very similar set of incorrect syntax, and provided direction there.


jarmova...@gmail.com

unread,
Mar 1, 2016, 5:28:40 AM3/1/16
to django...@googlegroups.com
You should use #burton in your CSS, not .burton. You set the css_id, not the css_class to burton.

Jarmo

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages