Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?
Check out this little tool: http://pypi.python.org/pypi/django-widget-tweaks Here's how I use it: https://github.com/oinopion/twitz/blob/master/templates/statuses/_status_update_form.html -- 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/-/fxTI8-tXeiQJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?
See this example: https://github.com/ebertti/django-registration-bootstrap have a example using django-registration On Mon, Dec 12, 2011 at 07:37, Lukas Vinclavwrote: > Hi, > > I am using Twitter Bootstrap in Django for a long time. Here are > directions how to achieve correct result. > > 1. Create new file for displaying forms in templates directory(e.g. > forms.html) > 2. In forms.html write the form displaying logic. This is just an example. > You have to set bootstrap's classes. > > {% if form.non_field_errors.0 %} > > {{ form.non_field_errors }} > > {% endif %} > > {% for field in form %} > {% if field.is_hidden %} > {{ field }} > {% else %} > > > {{ field.label }}: {% if field.field.required %} class="required">*{% endif %} > > > > > {{ field }} > > {% if field.errors %} > > {% for error in field.errors %} > {{ error|escape > }} > {% endfor %} > > {% endif %} > > {% if field.help_text %} > > {{ field.help_text }} > > {% endif %} > > > > {% endif %} > {% endfor %} > > 3. In template file where you are displaying form just call form.html > > {% block content %} > > {% csrf_token %} > {% include 'backend/partials/form.html' with form=question_form %} > > > > > > > > {% endblock %} > > Lukas Vinclav > > On Dec 12, 2011, at 8:28 AM, Victor Hooi wrote: > > Hi, > > I'm attempting to use Django forms with Twitter's CSS library Bootstrap ( > http://twitter.github.com/bootstrap/): > > The default form outputted by {{ form.as_p }} doesn't seem to be enough to > be formatted nicely with Bootstrap. > > You need to add a , as well as class="control-label" to each > . > > So for example, to output a single text field: > > > Text input > > > Help text here. Be sure to fill this out > like so, or else! > > > > Is there a way to easily get Django's form handling to produce a form like > this? (I'd like to avoid hardcoding every form field in my template if > possible). > > Cheers, > Victor > > -- > 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/-/BClad_qCrnEJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Ezequiel Bertti E-Mail: eber...@gmail.com MSN: eber...@hotmail.com Cel: (21) 9188-4860 VÁ PARA BÚZIOS!!! http://www.agh.com.br/ Ane Guest House -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?
Hi, I am using Twitter Bootstrap in Django for a long time. Here are directions how to achieve correct result. 1. Create new file for displaying forms in templates directory(e.g. forms.html) 2. In forms.html write the form displaying logic. This is just an example. You have to set bootstrap's classes. {% if form.non_field_errors.0 %} {{ form.non_field_errors }} {% endif %} {% for field in form %} {% if field.is_hidden %} {{ field }} {% else %} {{ field.label }}: {% if field.field.required %}*{% endif %} {{ field }} {% if field.errors %} {% for error in field.errors %} {{ error|escape }} {% endfor %} {% endif %} {% if field.help_text %} {{ field.help_text }} {% endif %} {% endif %} {% endfor %} 3. In template file where you are displaying form just call form.html {% block content %} {% csrf_token %} {% include 'backend/partials/form.html' with form=question_form %} {% endblock %} Lukas Vinclav On Dec 12, 2011, at 8:28 AM, Victor Hooi wrote: > Hi, > > I'm attempting to use Django forms with Twitter's CSS library Bootstrap > (http://twitter.github.com/bootstrap/): > > The default form outputted by {{ form.as_p }} doesn't seem to be enough to be > formatted nicely with Bootstrap. > > You need to add a , as well as class="control-label" to each > . > > So for example, to output a single text field: > > > Text input > > > Help text here. Be sure to fill this out > like so, or else! > > > > Is there a way to easily get Django's form handling to produce a form like > this? (I'd like to avoid hardcoding every form field in my template if > possible). > > Cheers, > Victor > > -- > 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/-/BClad_qCrnEJ. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Django Forms and Twitter Bootstrap - Add fieldset, div wrapper and CSS labels to Django Forms?
Hi, I'm attempting to use Django forms with Twitter's CSS library Bootstrap (http://twitter.github.com/bootstrap/): The default form outputted by {{ form.as_p }} doesn't seem to be enough to be formatted nicely with Bootstrap. You need to add a , as well as class="control-label" to each . So for example, to output a single text field: Text input Help text here. Be sure to fill this out like so, or else! Is there a way to easily get Django's form handling to produce a form like this? (I'd like to avoid hardcoding every form field in my template if possible). Cheers, Victor -- 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/-/BClad_qCrnEJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.