Giter Club home page Giter Club logo

django-bootstrap-form's Introduction

Hello world

django-bootstrap-form's People

Contributors

bianchimro avatar bitdeli-chef avatar bulv1ne avatar caumons avatar ckinsey avatar cyluss avatar devipriyasarkar avatar epicserve avatar frewsxcv avatar gsiegman avatar hugocs avatar ivanvenosdel avatar jiaaro avatar jodal avatar joshdata avatar jtauber avatar jweiher avatar karls avatar mattaustin avatar mpapierski avatar nikolas avatar nivl avatar prudnikov avatar ptrck avatar siloraptor avatar stephane avatar sunilmohanadapa avatar thesage21 avatar tzangms avatar zauddelig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-bootstrap-form's Issues

update pypi package

The package on pypi does not reflect recent changes. Please update package.

Support for bootstrap-datepicker or SelectDateWidget with django-bootstrap-form

Is there a good way to use bootstrap-datepicker or SelectDateWidget with django-bootstrap-form?

I can use from django.forms.extras.widgets import SelectDateWidget and get the field to render, but it renders as three stacked items. I want a horizontal display which is the way it renders if I user {{form}} instead of {{form|bootstrap}}

Anyone know of an elegant (and easy) way to accomplish this?

Sincerely,

Alan Viars

'SafeText' object has no attribute 'visible_fields'

return render(element, markup_classes)

File "XXXXXXX/lib/python2.7/site-packages/bootstrapform/templatetags/bootstrap.py", line 74, in render
for field in element.visible_fields():
AttributeError: 'SafeText' object has no attribute 'visible_fields'

Why limit to forms?

Great idea to keep bootstrap to tags in Django. Might be better than making real BootstrapForm, BootstrapModelForm, etc.

But why limit it to forms only? You could have tags to include Bootstrap CSS, additional JavaScript (required to make topbar etc work).

Required fields

How required are being rendered? Is there any difference between requiered and not required?

Performance Issues, ~6x longer to render than regular django forms

Here's the script that was used for the test:

from datetime import datetime

from bootstrapform.templatetags.bootstrap import bootstrap
from django import forms


class SomeTestForm(forms.Form):
    field_1 = forms.CharField(max_length=20)
    field_2 = forms.CharField(max_length=20)
    field_3 = forms.CharField(max_length=20)
    field_4 = forms.CharField(max_length=20)
    field_5 = forms.CharField(max_length=20)


def create_form():
    initial = {
        'field_1': 'Some random string 1.',
        'field_2': 'Some random string 2.',
        'field_3': 'Some random string 3.',
        'field_4': 'Some random string 4.',
        'field_5': 'Some random string 5.'
    }
    return SomeTestForm(initial=initial)

# Test rendering 1000 forms
forms = [create_form() for f in range(1000)]

# render using django form render
start_time_django_rendering = datetime.utcnow()

for form in forms:
    form.as_table()

end_time_django_rendering = datetime.utcnow()
total_django_rendering_time = (end_time_django_rendering - start_time_django_rendering)

print('Total django rendering time: {0}'.format(total_django_rendering_time))

# render using bootstrap form renderer
start_time_bootstrap = datetime.utcnow()

for form in forms:
    bootstrap(form)

end_time_bootstrap = datetime.utcnow()
total_bootstrap_time = end_time_bootstrap - start_time_bootstrap

print('Total bootstrap rendering time: {0}'.format(total_bootstrap_time))

Result test runs:
Run 1:

Total django rendering time:    0:00:01.293791
Total bootstrap rendering time: 0:00:06.579422

Run 2:

Total django rendering time:    0:00:01.298067
Total bootstrap rendering time: 0:00:06.548636

Run 3:

Total django rendering time:    0:00:01.304047
Total bootstrap rendering time: 0:00:06.530172

Run 4:

Total django rendering time:    0:00:01.293400
Total bootstrap rendering time: 0:00:06.584375

Run 5:

Total django rendering time:    0:00:01.294149
Total bootstrap rendering time: 0:00:06.550580

Multiwidget

I am using django-bootstrap-form in my project with a MultiWidget field which consists of a RadioSelectand a TextInput and the modul adds the form-control automatically to both fields.
Is there any way how to deal with this behavior without editing the module?

How to get field input types working?

Hi

How do I get field types to work? So far I cant get the html5 date type to work.

Here is my code:

-- listingform.py ---
from django.db import models
from django.forms import ModelForm
from listings.models import Listing

class ListingForm(ModelForm):
class Meta:
model = Listing
fields = ['title', 'description', 'reward', 'contact', 'duration','conditions', 'expires', 'published']

  • (this is all of it)
  • expires is a DateField

---Models.py---
eg expires = models.DateField('date expires')
...others...
but the renderer doesn't seem to be picking up on that?

-- views.py --
def researchers(request):
form = ListingForm()
return render(request, 'listings/list.html', {'form': form })

Please help? Do I need to do more in the html file? currently just `{{ form|bootrap}}
Do I need to do more in the form class?

About miss spell

example/app/templates/index.html
(23L)

below demostate how the form looks with bootstrap

I assume that it is "demonstrate".

update for 2.0 breaks 1.3/1.4 compatibility

Hi,

I accidentally updated this library and now my system using bootstrap 1.4 does not display forms the way it used to. Checkboxes with labels that were listed down the page are now jumbled together. Are you going to offer either a versioned pypi package that I can install a specific version of or a setting to support one vs. the other? I can help with either of these if you'd prefer.

Changelog is outdated

New versions were released in 2017. However, the CHANGES.txt seems stuck in 2015 :-)

radio field widget

First, thanks for the package, saved me a bunch of time.

It might be nice to support a list of radio fields, which currently come out wrong if you use Django's RadioSelect widget

I did it using code something like this: https://gist.github.com/2007671

You might want a different approach, though, looking at your forms.html

Rendering csrfmiddlewaretoken in forms

Currently, form rendering doesn't add the csrf token when rendering forms if you have django's CsrfViewMiddleware installed. It's kind of a pain in the butt to have to add that to every single form you want rendered. Why not check for installed apps and if CsrfViewMiddleware is installed, add the csrf_token by default since this will likely be the desired behavior? Then if you wanted, you could also create a form renderer that explicitly doesn't include the csrf hidden field when you don't want the csrf token:

{{ my_form|bootstrap_csrf_exempt }}

I don't mind doing the pull request for this, I just want to know why we wouldn't want to do this if there is a reason. What are other people's thoughts?

Deprecation warning for Django 1.10: template.render

Catching this deprecation warning when rendering using the template tag.

/bootstrapform/templatetags/bootstrap.py:80: RemovedInDjango110Warning: render() must be called with a dict, not a Context.
  return template.render(context)

'unicode' object has no attribute 'visible_fields'

I'm getting error: 'unicode' object has no attribute 'visible_fields'

Exception Type: AttributeError
Exception Value:
'unicode' object has no attribute 'visible_fields'
Exception Location: /Users/nano/code/turpial/kooshi/kenv/lib/python2.7/site-packages/bootstrapform/templatetags/bootstrap.py in render, line 74

Do you know how could it be fixed?

Add support for fieldsets

Currently, I don't believe there's a way to output fieldsets. This would help make the markup more flexible.

bootstrap_inline filter does not work with Bootstrap 2

I am trying to use the bootstrap_inline filter with Bootstrap 2.3.1 and a formset. I suspect that it is not working because of twbs/bootstrap@f662dff and the changes that @Nivl made to bootstrapform/templates/bootstrapform/field.html. The forms' fields display inline correctly if I move them out of the "form-group" divs.

Since the filter is not documented, it is not clear whether it only works with BS3 by design or this is just a bug.

Hiding bullets in <li> elements in multiple checkbox forms

Hey there,
I really enjoy using django-bootstrap-form in my project. Today I ran into the problem that there were bullet points in front of my checkboxes. I tried several CSS-code that didn't work for me. I found in your example the right solution and was wondering why you don't include this pice of code inside you package? I think that nobody needs the bullets when rendering checkbox forms.

Bye, aronadaal

Multiple help strings break HTML validity in help-block

When there are multiple help messages per field (eg. from multiple validators), the resulting output is formatted as an unordered list by django. When wrapped in:

<p class="help-block">
  {{ field.help_text|safe }}
</p>

(templates/bootstrapform/field.html) this produces invalid HTML. As a result, the ul is pushed out of wrapping paragraph, the styling breaks etc.
I believe changing paragraph tag to div would be a pretty safe solution.

Doesn't allow for multi column rows

If you have your form split vertically, then django-bootstrap-form fails, as the row declarations clash.

For example the following will not render correctly because the row has already been split.

<form action="" method="post">{% csrf_token %}.

    <div class="row">
        {{ form.non_field_errors }}
        <div class="col-md-6">
        <fieldset>
            <legend>Details</legend>
            {{ form.part_number | bootstrap_horizontal }}
            {{ form.grn | bootstrap_horizontal }}
            {{ form.job_number | bootstrap_horizontal }}
         </fieldset>
        </div>
        <div class="col-md-6">
        <fieldset>
            <legend>Cost and Quantity</legend>
            {{ form.serial_number | bootstrap_horizontal }}
            {{ form.qty | bootstrap_horizontal }}
            {{ form.cost | bootstrap_horizontal }}
        </fieldset>
        </div>
    </div><!-- end row div -->

<input type="submit" class="btn btn-default" value="Add or Update Carrier" />.
</form>

Note that adding a new row declaration doesn't seem to work either?:

 <div class="row">
        {{ form.non_field_errors }}
        <div class="col-md-6">
        <fieldset>
            <legend>Details</legend>
            <div class="row">
            {{ form.part_number | bootstrap_horizontal }}
            {{ form.grn | bootstrap_horizontal }}
            {{ form.job_number | bootstrap_horizontal }}
            </div>
         </fieldset>
        </div>
        <div class="col-md-6">
        <fieldset>
            <legend>Cost and Quantity</legend>
            <div class="row">
            {{ form.serial_number | bootstrap_horizontal }}
            {{ form.qty | bootstrap_horizontal }}
            {{ form.cost | bootstrap_horizontal }}
            </div>
        </fieldset>
        </div>
    </div><!-- end row div -->

screenshot from 2013-09-27 11 17 03

ChoiceModelField don't appears at form when editing

First, thanks a lot, this application is amazing.

I'm writing a Django open source project and using this application to improve user experience with twitter bootstrap.

So, there a problem with ChoiceModelFields when their values are filled, I don't know if this is properly a issue, but if you have passed for this before maybe you could help me.

Testing it, I putted a required ChoiceModelField in a form, filled and saved (In this case the field appears, cause there's no default value inputted)

When I tried to edit this form data the ChoiceModelField do not render in HTML DOM. When I tried to submit the form data, it is rendered with a required field error and no data filled.

I'm using the template tag {{ form|bootstrap }} instead do it field by field.

Do you have any idea that this can be?

best regards

João Dias de Carvalho Neto

Error messages pushed below input field

I'm finding that when trying to use in-line error message with textfields that django-bootstrap-form is pushing the errors below the text box, which is not the desired functionality in my case. The culprit is an empty span element with class="help-block". When I remove the empty span element, the issue is resolved and the error appears in-line. So I know the source of the problem, but I have no way to fix it since the form is generated for me. Thanks.

Fix #59: add_input_classes as filter

add_input_classes should return field to use it as a filter.

--- a/bootstrapform/templatetags/bootstrap.py
+++ b/bootstrapform/templatetags/bootstrap.py
@@ -45,20 +45,21 @@ def bootstrap_horizontal(element, label_cols='col-sm-2 col-lg-2'):

     return render(element, markup_classes)

 @register.filter
 def add_input_classes(field):
     if not is_checkbox(field) and not is_multiple_checkbox(field) \
        and not is_radio(field) and not is_file(field):
         field_classes = field.field.widget.attrs.get('class', '')
         field_classes += ' form-control'
         field.field.widget.attrs['class'] = field_classes
+    return field

I would open one-line PR if you want. Thanks.

Change tag name

Hi,

I propose to change the tag library name and the template tags itself from "bootstrap" to "bootstrapform", as, in my opinion, bootstrap is a little too generic in this case (other bootstrap apps for django already exist)

cheers
Mauro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.