On Feb 22, 2016 2:58 PM, <clarksonchri...@gmail.com> wrote: > > I have made an upload form button, that I need to be able to refers to tin my css code such that I can centre it on the web page. However the upload button is not constituted by any bootstrap like "btn" syntax, which is prevalent in example code. Instead is constituted by the following code: > > #forms.py > > class DocumentForm(forms.Form): > docfile = forms.FileField(label='Select a BAM file') > > ### no class or model declared#### > > And so I have taken some example code that I have tried to adapt into to my own code below and properly indented from the above code in forms.py. > > def __init__(self, *args, **kwargs): > super(####INSERT_TYPE####, self).__init__(*args, **kwargs) #what should i specify as a type? > self.helper = FormHelper() > self.helper.layout = Layout( > Fieldset( > '<h2 class="text-center">Edit data about your blog</h2>', > Div('description', css_class="col-md-12"), > ), > ButtonHolder( > Submit(css_class='btn-lg'), # not sure if this line is necessary for my purposes > css_class="text-center"), > ) > > Above, I am not sure what I should put in the place of "###INSERT_TYPE###" or whether the "Submit(css_class='btn-lg')" is necessary for me as I simply need to be able to "centre the text". > > My model for the upload is as follows: > > class Document(models.Model): > docfile = models.FileField(upload_to='BAMfile') > > And the HTML > > {% load crispy_forms_tags %} at the top > {% crispy form %} inside form tags > > I just need to know how I centre the text in the middle of my page... I can't believe that it could be this complicated.... >
Is this the only form where you have this requirement? If so, I wouldn't even bother trying to muck with the built-in elements for crispy-forms. Rather, just add an HTML() element to your Layout object instead using Submit() that contains the desirable <input> tag (basically render the button yourself manually). The HTML() object is detailed on this page: http://django-crispy-forms.readthedocs.org/en/latest/layouts.html#universal-layout-objects You can provide extra CSS classes to Submit() to help with styling, but I believe those are additive, and it sounds like the Bootstrap styling would get in the way of what you're trying to do. Otherwise your other option is to subclass the Submit() class and provide your own rendering, but I would only go to that trouble if this button is used in more than one location. http://django-crispy-forms.readthedocs.org/en/latest/layouts.html#creating-your-own-layout-objects -James -- 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+unsubscr...@googlegroups.com. To post to this group, send email to django-users@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/CA%2Be%2BciX7a2hhwwSgqpB18tCyaawAJfTaaddsH1GyE93Nv4DftA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.