earle / django-bootstrap Goto Github PK
View Code? Open in Web Editor NEWDjango Form Implementation of the Twitter-Bootstrap UI
License: Other
Django Form Implementation of the Twitter-Bootstrap UI
License: Other
class Meta:
layout = (
Fieldset("Please Login", "username", "password", ),
)
when i try to add a Fieldset as in the readme i get an error 'name 'Fieldset' is not defined' i am sure i am doing some noob mistake and not importing some thing but i am not sure what and google does not seem to have any results on why it does not work
Hello!
I can't use forms.HiddenInput() in Form Class:
class MyForm(BootstrapModelForm):
hidden_field = forms.HiddenInput()
Exception Value:
Caught NoSuchFormField while rendering: Could not resolve form field 'is_save_only'.
Exception Location: /home/daniel/.virtualenvs/load_tester/src/bootstrap/bootstrap/forms.py in render_field, line 82
Thanks.
If I were to raise forms.ValidationError("Error goes here"), it will be missing from your form rendering if using the as_div() method.
</div>
In setup.py, name is set to 'bootstrap'
Alas that name is taken in pypi: http://pypi.python.org/pypi/bootstrap
@earle - could you please pick another name, and perhaps deploy to pypi? (Given the choice, I'd much rather require a 0.1 from pypi than a Github HEAD...)
I've been using django-uni-form in the past. It can be used both in forms.py and as templatetag in a template.
The reason for templatetags support is simple: it's easy to write your own forms based on BootstrapForm/BootstrapModalForm/etc, however when you are using 3rd-party apps, replacing ALL forms.Form with BootstrapForm in source files would not be a good idea.
Actually there is another Django app which provides a simple templatetag "as_bootstrap" to convert Django standard form output to bootstrap style:
https://github.com/dyve/django-bootstrap-toolkit
It worked well until bootstrap upgraded to 2.0.0. It doesn't have fieldset support though (due to the nature of templatetags).
Both methods have their own advantage: in forms you have more control (like fieldset support, which is also provided in django-uni-form), and in templatetag you can simply convert standard forms used by 3rd-party apps to bootstrap style.
So I was wondering if you can add templatetags support in django-bootstrap? Probably a similar "as_bootstrap" templatetag.
Thanks.
Hi,
I was curious whether you had any plans for compatibility with Django ModelForms?
E.g. I'm using the new class-based CreateView, and I'm not sure how I would go about hooking django-boostrap into my forms?
Cheers,
Victor
Widget for the DateRange UI Element
I have created a widget for which is a modification of a CheckboxSelectMultiple from Django's core forms. I'm not sure how to integrate it in django-bootstrap code so I just created a gist:
Fix:
diff --git a/bootstrap/forms.py b/bootstrap/forms.py
index 988e5e4..7c3f4a7 100755
--- a/bootstrap/forms.py
+++ b/bootstrap/forms.py
@@ -160,11 +160,11 @@ class Fieldset(object):
""" Fieldset container. Renders to a <fieldset>. """
def __init__(self, legend, *fields, **kwargs):
- self.legend_html = legend and ('<legend>%s</legend>' % legend) or ''
+ self.legend_html = legend and legend or ''
self.fields = fields
self.css_class = kwargs.get('css_class')
def as_html(self, form):
class_str = self.css_class and (' class="%s"' % self.css_class) or ''
- return u'<fieldset%s>%s%s</fieldset>' % (class_str, self.legend_html, form.render_fields(self.fields), )
+ return u'<fieldset%s><legend>%s</legend>%s</fieldset>' % (class_str, unicode(self.legend_html), form.render_fields(self.fields), )
When attempting to initialise a form from an existing Model, I get the error "got an unexpected keyword argument 'instance'". Is it expected to be able to initialise a form object in this way?
From my views.py:
class MyForm(BootstrapForm):
class Meta:
model = MyModel
def process_request(request, brew_id):
if request.method == 'POST':
form = MyForm(request.POST)
else:
model = get_object_or_404(MyModel, pk=brew_id)
form = MyForm(instance=model)
Widget for the PrependedCheckbox UI element
Very useful package!
Seems people also use bootstrap-switch(http://www.bootstrap-switch.org/) a lot when dealing with forms, any plans to support that?
Widget for the AppendedCheckbox UI element
Just a suggestion but django-bootstrap could mean:
Perhaps something like django-bootstrap-forms?
bootstrap.forms in render_field
AttributeError: 'BoundField' object has no attribute '_auto_id'
Hi, I've been given an error:
Exception Value:
'Fieldset' object is not iterable
I did just like "Usage" showed, but no success.
Does anyone know about this?
Thanks.
hi is their way to get the forms to render inline ?
Hi guys,
Any idea how can I insert a thumbnail image alongside the upload button?
Hello,
Do you have a example on how to use the class FieldSet ?
Is it possible to remove the label beside the input field?
Fieldsets are being closed at the wrong place. This is what I'm seeing generated:
<form ...>
<fieldset><legend>Details</legend></fieldset>
<div class="control-group">...</div>
</form>
Bootstrap documentation shows examples with this format instead:
<form ...>
<fieldset>
<legend>Details</legend>
<div class="control-group">...</div>
</fieldset>
</form>
This is causing some weird spacing issues with Bootstrap 2.0.1 and django-bootstrap from the latest master.
It would be great to have an equivalent Bootstrap ModelForm to work with. I'm not sure how to approach it - what are your thoughts?
Hello,
I propose to add alert alert-error
to the error_list
method:
https://github.com/earle/django-bootstrap/blob/master/bootstrap/forms.py#L13
This way non_field_errors will be on a red background, consistent with fields' related errors.
It seems that instances of classes subclassed from BootstrapForm don't have a save method. As a result, it's not possible to save those forms.
Hello,
I've try django-bootstrap working with SessionWizardView and my first step form is empty. Not really empty because the hidden field <input type="hidden" name="inscription_wizard-current_step" value="0" id="id_inscription_wizard-current_step" />
is in the html source of the rendered page.
But others fields are not. I'm not enough django proof to find a solution but of course I agree testing.
It would be really great I think if the both can work together.
here is my code:
forms.py
class Step1Form(BootstrapForm):
class Meta:
layout = (
Fieldset("Please Login", "email_adresse", "telephone", ),
)
email_adresse = forms.EmailField(max_length=255)
telephone = FRPhoneNumberField(required=False)```
views.py
```class InscriptionWizard(SessionWizardView):
def get_template_names(self):
return 'clients/session_wizard.html'```
and html:
```
<form action="." method="post">{% csrf_token %}
{{ wizard.management_form }}
{% if wizard.form.forms %}
{{ wizard.form.management_form }}
{% for form in wizard.form.forms %}
{{ form }}
{% endfor %}
{% else %}
{{ form }}
{% endif %}
<input type="submit">
</form>
{% endblock %}
```
If you have any idea ... let me jnow.
Best regards an thanks a lots for the job.
Alain
Widget for the Optionlist UI element
I have a form where I want to use two BootstrapModelForm instances. When unpacking the data from these on postback using the prefix parameter I get the following error:
'QueryDict' object has no attribute '_meta'
I am using the regular "prefix" attribute to specify the form output prefix like this:
user_form = UserForm(instance=request.POST, prefix="user")
The error occurs when Bootstrap is setting up the ModelForm object on line 149:
class BootstrapModelForm(forms.ModelForm, BootstrapMixin):
def __init__(self, *args, **kwargs):
forms.ModelForm.__init__(self, *args, **kwargs)
Has django-bootstrap stripped some data along the way?
hi is their way to get the forms to render inline ?
Hi.
i'm having trouble on using this plugin for the UpdateView and the form that is auomatically created.
where i can find help?
Is is possible to allow the addition of a custom id to a field such that it looks something like this:
<div id="div_paypal_email" class="control-group">
<label class="control-label">Paypal Email</label>
<div class="controls">
<input id="id_paypal_email" type="text" name="paypal_email" value="" maxlength="75">
<p class="help-block"></p>
</div>
</div>
Widget for PrependText UI element
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.