pbucher / django-bootstrap-datepicker Goto Github PK
View Code? Open in Web Editor NEWDjango Widget for bootstrap-datepicker
License: Apache License 2.0
Django Widget for bootstrap-datepicker
License: Apache License 2.0
Hi, I'm experiencing the below error using django v1.10.2:
Django Version: 1.10.2
Exception Type: TypeError
Exception Value: build_attrs() takes from 1 to 2 positional arguments but 3 were given
Exception Location: .../bootstrap_datepicker/widgets.py in render, line 115
The culprit seems to be the below line as build_attrs
doesn't expect attrs
:
input_attrs = self.build_attrs(attrs, extra_attrs)
Replacing the above with:
if attrs:
self.attrs.update(attrs)
input_attrs = self.build_attrs(extra_attrs)
seems to work.
Hi, I would like to use this as a multidate picker for scheduling. My thinking was to use a ForeignKey field to connect the to and use that to populate the DatePicker. Is this the best way to do this?
class Product(models.Model):
desc = models.charfield()
class ProductBooking(models.Model):
product = models.ForeignKey('catalogue.Product')
booking_date = models.DateField()
When used out of the box I get a JS console error telling me datepicker is not a function. Dropping in the bootstrap-datepicker.js from the CDN (instead of using the one under /static) resolved the issue for me.
In DJango 2.0, JSFiles
object needs to be reversible, otherwise it raises an error
TypeError at /some_url
'JSFiles' object is not reversible
The issue can be solved by either renaming the __iter__
method to __reversed__
or by adding a __reversed__
method to JSFiles
Object. Adding a method instead of renaming keeps backward compatibility.
At least I think it is a 1.11 issue.
When trying to use the widget as is I got an unexpected argument
exception on the line
input_attrs = self.build_attrs(attrs, type=self.input_type, name=name)
I fixed it by adding the type
and name
to the attrs
manually beforehand.
It is a regret that the current day is not highlighted in the popup calendar.
I would like the datepicker to display all the time (as inline) how do I need to change the widget to do this?
Rather than omitting the javascript initialization if the options
parameter isn't set, it would be nice if the DatePicker simply chose default options. Probably the two already in the readme.
Let me know if this is helpful and happy to make a PR.
Either I am missing something or this is just a date picker...its a bit misleading when looking for a date time picker. Is this the case?
You might get the following error in recent Django versions:
'DatePicker' object has no attribute '_format_value'
The reason:
Django 2.0: Widget.format_value has been renamed from _format_value to format_value to make it a part of the public API.
I made a fix in my fork by changing the function name in widget.py file . Works fine.
On Django 2.1 I get the follwing traceback when adding the DatePicker widget, while on Django 2.0 it works fine:
Traceback (most recent call last):
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/core/handlers/base.py", line 156, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/core/handlers/base.py", line 154, in _get_response
response = response.render()
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/response.py", line 106, in render
self.content = self.rendered_content
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/response.py", line 83, in rendered_content
content = template.render(context, self._request)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 171, in render
return self._render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
return self.nodelist.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/loader_tags.py", line 62, in render
result = block.nodelist.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 937, in render
bit = node.render_annotated(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
return self.render(context)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/template/library.py", line 192, in render
output = self.func(*resolved_args, **resolved_kwargs)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/templatetags/bootstrap4.py", line 421, in bootstrap_form
return render_form(*args, **kwargs)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/forms.py", line 39, in render_form
return renderer_cls(form, **kwargs).render()
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/renderers.py", line 77, in render
return mark_safe(self._render())
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/renderers.py", line 208, in _render
return self.render_errors() + self.render_fields()
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/renderers.py", line 174, in render_fields
bound_css_class=self.bound_css_class,
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/forms.py", line 55, in render_field
return renderer_cls(field, **kwargs).render()
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/renderers.py", line 77, in render
return mark_safe(self._render())
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/bootstrap4/renderers.py", line 508, in _render
html = self.field.as_widget(attrs=self.widget.attrs)
File "/home/hexa/.local/share/virtualenvs/devconf3-uk6jVlS4/lib/python3.6/site-packages/django/forms/boundfield.py", line 93, in as_widget
renderer=self.form.renderer,
TypeError: render() got an unexpected keyword argument 'renderer'
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.