zostera / django-bootstrap3 Goto Github PK
View Code? Open in Web Editor NEWBootstrap 3 integration with Django.
Home Page: http://django-bootstrap3.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
Bootstrap 3 integration with Django.
Home Page: http://django-bootstrap3.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
pip install django-bootstrap3
error: invalid command 'egg_info'
Complete output from command python setup.py egg_info:
C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution op
ion: 'install_requires'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'egg_info'
When I run create a form, based on the demo templates, the 'Submit' button works great, but the 'Cancel' button seems to behave the same as the submit. In my case: hitting 'Cancel' before all required fields are filled generates "This field is required." messages. And if all fields are filled, then the form is submitted as if 'Submit' was pressed. Also, I'm using generic views to generate my forms.
I appreciate all of your help and work.
{% extends 'base.html' %}
{% load bootstrap3 %}
{% block content %}
<form action="." method="POST">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons submit='OK' cancel='Cancel' %}{% endbuttons %}
</form>
{% endblock %}
Make an option for {% bootstrap_css %} to also include the bootstrap theme
(nice gradients on buttons etc)
http://netdna.bootstrapcdn.com/bootstrap/3.0.1/css/bootstrap-theme.min.css
My form includes a date field.
I'd love to have a component date picker - click the box and a small month calendar pops up, with navigation arrows. Pretty standard JS functionality.
I have been trying to implement bootstrap-datepicker (https://github.com/eternicode/bootstrap-datepicker) without success, as it seems there is no way to add an extra css/js reference to any form field or widget in particular.
I've tried using the method that the Django docs recommends:
https://docs.djangoproject.com/en/1.6/topics/forms/media/#paths-in-asset-definitions
Since the docs explain exactly my problem, it's almost verbatim. The date field in my form uses the CalendarWidget(). The relative css and js files are loaded on the page.
But for some reasons the css get's ignored, and I have no special component field.
Note that I also tried the same a bit further down the page ("for forms") but it also didn't work.
I'm not 100% sure if this is a bug (b0rked), a question (help!) or a feature request (I'd like this please).
Error during template rendering
In template C:...............\blog\index.html, error at line 21
<form action="/url/to/submit/" method="post" class="form">
20 {% csrf_token %}
21 {% bootstrap_form form %}
22 {% bootstrap_form_buttons %}
23
24 {% bootstrap_icon "star" %} Submit
25
26 {% end_bootstrap_form_buttons %}
Hey,
is it possible to use the {% bootstrap_form form %} command and add the Column sizing attribute to some elements?
Thanks
The opening and closing of the tags will not validate through Pycharms inspection due to the extra underscore in the closing tag
compare:
{%block%}
{%endblock%}
to:
{% bootstrap_form_buttons %}
{% end_bootstrap_form_buttons %}
pip install git+git://github.com/dyve/django-bootstrap3.git
results in
IOError: [Errno 2] No such file or directory: '/tmp/pip-FQRGhU-build/setup.py'
Can we take out the app as a reusable one and add setup.py so that users an test it out please?
forms.py has a "# Set required attribute" section. When a object is retrieved that already has the file set, the form currently can't be submitted without choosing the file in the file picker.
Might need some code that says "if the field is a file field and is required and already has a file uploaded, don't mark it as required".
Well I've been following this guide to create a form from extended User model and I've got an error with your tag, although {{ form.as_p }}
works well.
Is django-bootstrap3 django1.5 compatible?
Exception Type: TypeError
Exception Value: sequence item 0: expected string, __proxy__ found
When using this project with django 1.6 south 0.8.4 getting this error when running syncdb:
File "C:\Program Files (x86)\JetBrains\PyCharm 3.0\helpers\pycharm\django_manage.py", line 23, in
run_module(manage_file, None, 'main', True)
File "C:\Python27\Lib\runpy.py", line 176, in run_module
fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 82, in run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in run_code
exec code in run_globals
File "C:\Users\djcastillo\PycharmProjects\subtracker\manage.py", line 10, in
execute_from_command_line(sys.argv)
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\core\management__init.py", line 399, in execute_from_command_line
utility.execute()
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\core\management__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
self.execute(_args, *_options.dict)
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\core\management\base.py", line 285, in execute
output = self.handle(_args, _options)
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\core\management\base.py", line 415, in handle
return self.handle_noargs(_options)
File "C:\Users\djcastillo\subtracker\lib\site-packages\south\management\commands\syncdb.py", line 68, in handle_noargs
migrations = migration.Migrations(app_label)
File "C:\Users\djcastillo\subtracker\lib\site-packages\south\migration\base.py", line 64, in call
self.instances[app_label] = super(MigrationsMetaclass, self).call(app_label_to_app_module(app_label), *_kwds)
File "C:\Users\djcastillo\subtracker\lib\site-packages\south\migration\utils.py", line 41, in app_label_to_app_module
app = models.get_app(app_label)
File "C:\Users\djcastillo\subtracker\lib\site-packages\django\db\models\loading.py", line 186, in get_app
raise ImproperlyConfigured("App with label %s is missing a models.py module." % app_label)
django.core.exceptions.ImproperlyConfigured: App with label bootstrap3 is missing a models.py module.
When using django-autocomplete-light's ChoiceWidget in a form and rendering the form with django-bootrstrap3's bootstrap_form one of the input-fields gets 2 class attrs (class="form-control" and class="autocomplete")
This does not validate and breaks for example taconite's ajax loading of a page with these forms.
Reproduce:
$ pip install django-bootstrap3
Downloading/unpacking django-bootstrap3
Downloading django-bootstrap3-2.0.0.tar.gz
Running setup.py egg_info for package django-bootstrap3
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3/setup.py", line 66
print "You probably want to also tag the version now:"
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3/setup.py", line 66
print "You probably want to also tag the version now:"
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3
Storing complete log in /home/lukasz/.pip/pip.log
pip.log:
------------------------------------------------------------
./pip run on Sat Nov 9 19:16:56 2013
Downloading/unpacking django-bootstrap3
Getting page https://pypi.python.org/simple/django-bootstrap3/
URLs to search for versions for django-bootstrap3:
* https://pypi.python.org/simple/django-bootstrap3/
Analyzing links from page https://pypi.python.org/simple/django-bootstrap3/
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.1.tar.gz#md5=b20e02c133b77bebe1c4756bd0968e99 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.1
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.2.tar.gz#md5=f18a0df3249967df8cc650cf73f8c306 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.2
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.3.tar.gz#md5=6e57d8c304be367e380b2b1783f67bcc (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.3
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.4.tar.gz#md5=fcb916dca23db2cc1e5ae663bbc2b697 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.4
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.5.tar.gz#md5=50891dd538f9df423a686f20137d4253 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.5
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.6.tar.gz#md5=759e298b33160384364c1c70b6f6e836 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.6
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.0.7.tar.gz#md5=f2034f3f5d53940f1fdc1cf0a47fd7b4 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.0.7
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-0.1.0.tar.gz#md5=5ca72e663e731ed52fcd2fd372691136 (from https://pypi.python.org/simple/django-bootstrap3/), version: 0.1.0
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-1.0.0.tar.gz#md5=c0fe07d1982da391d1b78880531463f7 (from https://pypi.python.org/simple/django-bootstrap3/), version: 1.0.0
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-1.1.0.tar.gz#md5=fdcdffc73f580b5b512168ad1ff5ed19 (from https://pypi.python.org/simple/django-bootstrap3/), version: 1.1.0
Found link https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-2.0.0.tar.gz#md5=ac982724da7d1593bb15abb75bbe8fca (from https://pypi.python.org/simple/django-bootstrap3/), version: 2.0.0
Using version 2.0.0 (newest of versions: 2.0.0, 1.1.0, 1.0.0, 0.1.0, 0.0.7, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1)
Downloading django-bootstrap3-2.0.0.tar.gz
Downloading from URL https://pypi.python.org/packages/source/d/django-bootstrap3/django-bootstrap3-2.0.0.tar.gz#md5=ac982724da7d1593bb15abb75bbe8fca (from https://pypi.python.org/simple/django-bootstrap3/)
Running setup.py egg_info for package django-bootstrap3
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3/setup.py", line 66
print "You probably want to also tag the version now:"
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3/setup.py", line 66
print "You probably want to also tag the version now:"
^
SyntaxError: invalid syntax
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3
Exception information:
Traceback (most recent call last):
File "/home/lukasz/workspace/virtualenv/env-3.3.2/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/basecommand.py", line 139, in main
status = self.run(options, args)
File "/home/lukasz/workspace/virtualenv/env-3.3.2/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/commands/install.py", line 266, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/home/lukasz/workspace/virtualenv/env-3.3.2/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/req.py", line 1057, in prepare_files
req_to_install.run_egg_info()
File "/home/lukasz/workspace/virtualenv/env-3.3.2/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/req.py", line 236, in run_egg_info
command_desc='python setup.py egg_info')
File "/home/lukasz/workspace/virtualenv/env-3.3.2/lib/python3.3/site-packages/pip-1.3.1-py3.3.egg/pip/util.py", line 662, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in /home/lukasz/workspace/virtualenv/env-3.3.2/build/django-bootstrap3
Trying to migrate from bootstrap_toolkit to bootstrap3, both released by you. Bootstrap_toolkit works perfectly, however when I download bootstrap3, add to settings.py and include the appropriate tag { load bootstrap3 } I get a Django error that states bootstrap3 is not a valid tag library. Checked the directory /usr/local/lib/python2.7 /distpackage and bootstrap3 is in the correct spot, along with the old bootstrap_toolkit. Am I missing something?
Best,
Greg
The pagination script uses calls of unicode
primitive which is not available in python3
In bootstrap3 /templatetags/bootstrap3.py
lines 220 and 232.
Unless I'm missing something, there isn't any support for input group addons in this version (http://getbootstrap.com/components/#input-groups). It appears that there was in the old version of this (https://github.com/dyve/django-bootstrap-toolkit/blob/master/bootstrap_toolkit/templates/bootstrap_toolkit/field_prepend_append.html).
According to http://validator.w3.org/check
Pages with checkboxes don't validate due to error
Attribute placeholder not allowed on element input at this point.
Attributes for element input:
It'd be great if there is a usage as in django-bootstrap-toolkit
{{ form.name|as_bootstrap }}
Hello guys!
i can not find the widgets.BootstrapDateInput in the bootstrap3 as in the earlier version:
is there an alternative way doing the same?
thanks
Is it possible to get {% bootstrap_form %} to produce anything like the following HTML?:
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
Note: example HTML copied from http://stackoverflow.com/a/18620303
Using django-bootstrap3==2.5.4 and django==1.6.1, I have the following error:
Traceback:
File "c:\python27\lib\site-packages\django\core\handlers\base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File XXX\users\views.py" in create
56. return render_to_response('users/addUser.html', {'formRegistration': formRegistration}, context_instance=RequestContext(request))
File "c:\python27\lib\site-packages\django\shortcuts\__init__.py" in render_to_response
29. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "c:\python27\lib\site-packages\django\template\loader.py" in render_to_string
169. return t.render(context_instance)
File "c:\python27\lib\site-packages\django\template\base.py" in render
140. return self._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
134. return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
840. bit = self.render_node(node, context)
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
78. return node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
123. return compiled_parent._render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in _render
134. return self.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
840. bit = self.render_node(node, context)
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
78. return node.render(context)
File "c:\python27\lib\site-packages\django\template\loader_tags.py" in render
62. result = block.nodelist.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
840. bit = self.render_node(node, context)
File "c:\python27\lib\site-packages\django\template\debug.py" in render_node
78. return node.render(context)
File "c:\python27\lib\site-packages\django\template\base.py" in render
1125. return func(*resolved_args, **resolved_kwargs)
File "c:\python27\lib\site-packages\bootstrap3\templatetags\bootstrap3.py" in bootstrap_form
79. return render_form(*args, **kwargs)
File "c:\python27\lib\site-packages\bootstrap3\forms.py" in render_form
46. exclude=exclude,
File "c:\python27\lib\site-packages\bootstrap3\forms.py" in render_field
138. help_html = ' '.join(help_text_and_errors)
Exception Type: TypeError at /users/create/0
Exception Value: sequence item 0: expected string or Unicode, __proxy__ found
Local vars
Variable Value
show_label True
form_control_class u'form-control'
rendered_field u'<input class="form-control" id="id_password2" name="password2" placeholder="Confirmation du mot de passe" required="required" title="Saisissez le m\xeame mot de passe que pr\xe9c\xe9demment, pour v\xe9rification." type="password" />'
list_to_class False
put_inside_label False
label_class u''
wrapper u''
widget_attr_placeholder u''
field <django.forms.forms.BoundField object at 0x038A1A90>
form_group_class u'form-group'
show_help True
widget_attr_title u''
exclude u''
field_class u''
help_text_and_errors [<django.utils.functional.__proxy__ object at 0x030B3BD0>]
widget_attr_class u''
layout u''
django-bootstrap3==2.5.3 dosen't have the problem.
Bests,
In forms.py, line 37-. suggest add a line as following:
for field in form:
fields.append(render_field(
field,
layout=layout,
form_group_class=form_group_class,
field_class=field_class,
label_class=label_class,
show_label=form.auto_id, # add this line
show_help=show_help,
exclude=exclude,
))
Is there a quick way to render a grid of forms (from formsets): labels in header and each form's fields in a row? I didn't find this in code. What approach would you use?
And if this needs to be done outside of bootstrap3 (from HTML) is there a way to render just the HTML field (i.e. just ). I didn't find this in code either.
Hello
SelectDateWidget and ownmade widgets will have their input full-size and on seperate lines.
I wrote some simple Jquery code to modify these (atleast with 2 and 3 on 1 line):
$('.form-group > div').each(function () {
if ($(this).find('.form-control').length == 2) {
$(this).find('.form-control').css({
'width': '49.5%',
'display': 'inline-block'
})
} else if ($(this).find('.form-control').length == 3) {
$(this).find('.form-control').css({
'width': '32.7%',
'display': 'inline-block'
})
}
})
Is there some easier way to do this automatically when the form is rendered?
{% bootstrap_javascript %} introduces a jQuery dependency. This should be documented, with a link to a recommended Django package that adds jQuery static resources, such as https://pypi.python.org/pypi/django-jquery.
Trying to use bootstrap_form on the form @https://github.com/pennersr/django-allauth/blob/master/allauth/templates/account/login.html#L34 like
{% load bootstrap3 %}
{% bootstrap_form form %}
results in
TypeError at /accounts/login/
coercing to Unicode: need string or buffer, __proxy__ found
at bootstrap3/forms.py in render_field, line 97
I was following your example from template and this doesn't work as expected:
{% bootstrap_javascript jquery=True %}
Correct me if I'm wrong but what I see in this file it seems that include_jquery
never will be True
?
Or you have to set it manually somehow..?
Update: it looks like you trying to get settings from settings.py?
from django.conf import settings
.....
BOOTSTRAP3.update(getattr(settings, 'BOOTSTRAP3', {}))
Even if I override settings your app doesn't see them. Maybe because my settings files is not settings.py
, I've splitted settings.py
to development.py
and production.py
.
In my opinion there's no need to have this option in default settings at all, because when you including bootstrap jquery is False by default.
Just lik ein bootstrap_toolkit, a form layout must be specified in the layout parameter.
{% bootstrap_form form %} {# default, vertical #}
{% bootstrap_form form layout="horizontal" %}
{% bootstrap_form form layout="inline" %}
Currently, if one extends the bootstrap3 templates, there's no placeholder in the META tags for adding in page-specific JavaScript or CSS.
This is especially problematic if that JavaScript I want to add depends on jQuery because the jQuery is always instead just before the </body>
tag and my scripts won't know that the global jQuery
is defined.
I'd suggest adding in a placeholder in META that sub-templates could override for page-specific JavaScript. Or, we could add a placeholder that will appear below the bootstrap3 included JavaScript and before the </body>
tag.
I try to get horizontal form that will be looks like form from bootstrap guide. I used:
{% bootstrap_form form layout='horizontal' %}
{% buttons %}
{% bootstrap_button 'Sign in' 'submit' %}
{% endbuttons %}
But the button is in the wrong position.
Is there any horizontal
option for the bootstrap_button
templatetag? How can I achieve that?
bootstrap_for
template tag does not support named view with namespace
myapp urls.py
urlpatterns = patterns('',
url(r'^create/$', 'myadd.view.myview_create', name='make_magic' ),
)
project urls.py
urlpatterns = patterns('',
url(r'^$', include("myapp.urls", namespace="myapp")),
)
on template:
{% load i18n %}
{% load django_bootstrap_breadcrumbs %}
{% block breadcrumb_head %}
{% clear_breadcrumbs %}
{% breadcrumb_for "myapp:make_magic" %}
{% trans "Make Magic" %}
{% endbreadcrumb_for %}
{% endblock breadcrumb_head %}
The result is an incorrect url. The generated code is:
<a href="myapp:make_magic">
Make Magic
</a>
the django url template tag can properly resolve this url.
I suppose that perhaps part of the code solves the url, could be replaced by a direct call to the django url template tag
In forms.py:183 unnecessary another btn is added to attrs['class']
Hi,
field errors are not displayed in inline forms.
I traced it down to line 45 in forms.py.
if field.is_hidden and field.errors:
errors += field.errors
It seems that only errors of hidden fields are displayed. I removed the "field.is_hidden" from the if statement and the errors are now displayed.
cheers
{% bootscript_javascript jquery=True %} renders to
<script src="//code.jquery.com/jquery.min.js" async></script><script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js" async></script>I'm not positive about what 'async' does, but apparently sometimes jquery isn't loaded in time (this is: before bootstrap) and I got the error
Bootstrap requires jQuery
I entered the scripts manually, removed "async" from both and now it works without errors.
(thanks for this btw, really useful for me!)
Hello!
I have Django==1.5.4
and django-bootstrap3==2.0.0
and multilingual site.
All chunks in template translated successfully except form generated by django-bootstrap3. It's label not translated. In templates text ramains as in form defination ...
Hi,
I have a simple forms.Form instance with three forms.ChoiceField fields each with choices= set to define acceptible choices. The form method is GET and it is rendered using {% bootstrap_form form %}. When an invalid parameter is requested via GET the field's help text/error message prints the requested parameter un-escaped.
Example: http://url.tld/app/view?param1="><script>alert(document.cookie)</script>'¶m2=NA¶m3=NA
Returns: <span class="help-block">Select a valid choice. "><script>alert(document.cookie)</script>' is not one of the available choices.</span>
View logic:
if request.method == 'GET':
form = TheForm(request.GET)
if form.is_valid():
<Logic here>
else:
form = SortForm()
My current fix is to completely reset the form if is_valid() returns False for this particular form (it's the only GET on the site). I'm running Django 1.5.5 and django_boostrap3 2.0.0.
Cheers,
sp1ky
I thought about a generic BootstrapButton
class that renders as <button class="btn btn-default">Label</button>
and other classes inheriting from that class that render as <a href="/some/url/" class="btn btn-warning">Label</a>
. Furthermore I'd like to propose the ability to render button groups and dropdowns using those buttons.
I'm happy to implement that, but want to know the general thoughts about it. Is it a feature worth implementing?
Base draft:
class BaseBootstrapButton(object):
button_type = 'button' # or submit, reset, link
css_classes = 'btn' # extended by sub-classes
def __init__(self, label, css_classes=None, button_type=None):
self.label = label
if not css_classes is None:
self.css_classes = add_css_class(self.css_classes, css_classes)
if not button_type is None:
self.button_type = button_type
def get_html_attrs(self, **kwargs):
attrs = {
'class': self.css_classes,
}
attrs.update(kwargs)
return attrs
def __str__(self):
return format_html(
'<{button_type}{attrs}>{label}</{button_type}>',
button_type=self.button_type,
attrs=flatatt(self.get_html_attrs()),
label=self.label
)
class BootstrapLinkButton(BaseBootstrapButton):
button_type = 'a'
def __init__(self, label, link, css_classes=None):
if not css_classes is None:
css_classes = add_css_class(css_classes, 'btn-default')
super(BootstrapLinkButton, self).__init__(label, css_classes)
self.link = link
def get_html_attrs(self, **kwargs):
return super(BootstrapLinkButton, self).get_html_attrs(href=self.link)
It would be nice if there was some way to render differently required fields, like with boldface, or with and asterisk.
I was trying to use bootstrap3 with django version 1.6 and getting following error.
I have installed bootstrap using command
$pip install django-bootstrap3
and
Following is my django settings.py file content:
INSTALLED_APPS = (
'bootstrap3',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# User defined apps
'register',
I am using django testserver to run the application. Am I missing something ?
Any help towards this is greatly appreciated. Thanks in advance.
the old bootstrap2 had a 1-1 mapping with django messages, so you could write:
class= {{message.tags }}-alert
Now 'error' changed to 'danger' in bs3, so any way this app can compensate for that? I added it manually. Is that the best way to handle that or could you squeeze this in to this app?
{% for message in messages %}
<div{% if message.tags %} class="alert alert-{{ message.tags }} {% if message.tags = 'error' %}alert-danger{%endif%}"{% endif %}>
<button type="button" class="close" data-dismiss="alert">×</button>
{{ message|safe }}
</div>
{% endfor %}
When I test the demo with Django 1.6.1 - the javascript files are included twice:
This is <em>bootstrap3</em> for <strong>Django</strong>.
</div>
<script src="//code.jquery.com/jquery.min.js"></script><script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery.min.js"></script><script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
using
{% bootstrap_javascript 1 %}
On Chrome and Safari, $('#someid').popover() function report as 'undefined'
remove 'async' in 'bootstrap3.py' line 62. Everything is ok.
javascript += '<script src="{url}" async></script>'.format(url=url)
change to:
javascript += '<script src="{url}"></script>'.format(url=url)
I see in render_label there is some code for specifying the 'for' in a label () but I can't figure out how to use this.
I want my s to have for=.
What is the syntax I must use to load a bootswatch css file? I cannot find where or how I can do that.
The following html file, used in a brand new django project does not produce the correct output. The example is taken from http://getbootstrap.com/css/#grid and the code should produce an output similar to the one displayed there. Instead it displays the page as shown in the attached image:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
{% load bootstrap3 %}
{# Load CSS and JavaScript #}
{% bootstrap_css %}
{% bootstrap_javascript %}
<body>
<div class="row">
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
<div class="col-md-8">.col-md-8</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-6">.col-md-6</div>
<div class="col-md-6">.col-md-6</div>
</div>
</body>
</html>
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.