nkunihiko / django-bootstrap3-datetimepicker Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
It would be good to be able to push all the script bits created by django-bootstrap3-datetimepicker to the end of the file, rather than the beginning.
Hello,
After selecting a date, I can't clear the value, the date still remains.
date_from = forms.DateField(
required=False,
widget=DateTimePicker(options={'format': 'DD/MM/YYYY',
'pickTime': False}))
I'm using django-bootstrap3
.
The README says to add 'bootstrap3_datetime'
to INSTALLED_APPS
, but I had to use 'bootstrap3_datetime'
.
I figure this is a typo somewhere, and that I'd report it!
Using the current bootstrap3-datetimepicker, I cannot select dates before 1970.
see similar issue with angular package.
It appears newer versions of the bootstrap3-datetimepicker library fix this. I noticed a few pull-requests to integrate newer versions of the bootstrap3-datetimepicker in this package. Are there plans to integrate updated versions?
Currently this repository doesn't appear to have any tags for versions.
Can you please tag the versions so they can be referenced externally?
Nice package, but it look outdated,
I've got the problems when run on actual Django 1.11
Bootstrap v3.3.6
Build_attrs
in widget.py
raise a python error. #67 pull is helping, but(index):34 Uncaught TypeError: jQuery(...).datetimepicker is not a function
is in browser consoleCould you suggest a actual working fork?
The following field:
forms.DateField(required=True, widget=DateTimePicker())
...when rendered, does not have the star indicating required next to its label. If I don't use the DateTimePicker, the star is correctly rendered.
DateTimePicker defines Media.js to bring in the css and javascript, but doesn't include moment.
So I tried to derive off of DateTimePicker and add moment -- but Django emits media resource inclusions in the order of base class up.
I monkeypatched:
DateTimePicker.Media.js = ['moment/moment.js',] + [js for js in DateTimePicker.Media.js]
Which worked. But if this encapsulation is not including Moment, but is including the datetimepicker js/css, there needs to be a way to also define moment as a requirement.
Or leave it all up to the user of the class.
How i put initial date?
this is my forms.py
from bootstrap3_datetime.widgets import DateTimePicker
from django import forms
class serviceForm(forms.ModelForm):
serviceRequestDate = forms.DateTimeField(
widget=DateTimePicker(options={"format": "YYYY-MM-DD",
"pickTime": False}))
class Meta:
model = serviceBooking
fields = ('serviceRequestDate', 'serviceRequestTime', 'serviceDetails')
this is my template;
<form method="post" action="/services/book/">{% csrf_token %}
<div class="col-xs-12 col-sm-6">
<div class="form-group required">
<label for="InputName">Date <sup>*</sup> </label>
{{form.serviceRequestDate}}
</div>
<div class="form-group required">
<label for="InputLastName">Number of Hours <sup>*</sup> </label>
{{form.serviceRequestTime}}
</div>
</div>
<div class="col-xs-12 col-sm-6">
<div class="form-group required">
<label for="InputZip">Tell us about your work? <sup>*</sup></label>
{{form.serviceDetails}}
</div>
</div>
</form>
I have included the {{form.media}} tag in my head but I'm getting undefined is not a function error in my console and the datepicker is not opening.
<script>
$(function() {
$("#id_serviceRequestDate_picker").datetimepicker({"pickTime": false, "language": "en-us", "format": "YYYY-MM-DD"});
});
</script>
Is there a way to cleanly disable sets of dates? For example, I'm trying to disable all dates greater than today. The JS docs say to call moment, but since widget attrs are passed in as strings, I'm not sure how this could be accomplished:
options={"format": "YYYY-MM-DD HH:mm:ss", "disabledDates": "[moment.max()]" }
startDate
option only understand dates in format month/day/year
.
I have system language defined as Italian, dates are shown accordingly, but startDate MUST be in US format. Is this a desired behavior?
Under django 1.8 I got warning:
/usr/local/lib/python2.7/dist-packages/bootstrap3_datetime/widgets.py:2: \
RemovedInDjango19Warning: The django.forms.util module has been
renamed. Use django.forms.utils instead
First, let me thank you for this awesome module.
I'd like to propose making the Calendar/Clock Glyphicons on the left instead of being on the right, so when ever an validation icons - usually shown on the right - appear, they don't interfere with the icon's position.
An image describing the final output is attached.
A patch that can be applied to this issue:
diff --git a/bootstrap3_datetime/widgets.py b/bootstrap3_datetime/widgets.py
index f006f80..f079b12 100644
--- a/bootstrap3_datetime/widgets.py
+++ b/bootstrap3_datetime/widgets.py
@@ -70,10 +70,10 @@ class DateTimePicker(DateTimeInput):
html_template = '''
<div%(div_attrs)s>
- <input%(input_attrs)s/>
<span class="input-group-addon">
<span%(icon_attrs)s></span>
</span>
+ <input%(input_attrs)s/>
</div>'''
js_template = '''
This is quite strange.
now = timezone.localtime(timezone.now())
# US date format because DatePicker wants like this
now = now.strftime('%m/%d/%y')
Now I define a field in a Form
:
start = forms.DateTimeField(required=True,widget=DateTimePicker(options={
'pickTime': False,
'startDate': now
}))
and everything goes well. But then I subclass the Form
and in the subclass __init__
I want to modify the field with time picking as well (now
is defined exactly as above):
self.fields['start'].widget = DateTimePicker(options={
'pickTime': True,
'startDate': now,
})
Now the issue: starting date is tomorrow, the day after.
I have to force it with:
now = now - relativedelta(days = 1)
Maybe it's not a startDate
issue but something related to Django?
Caused by the lack of relative import of widgets
in fields.py
(?)
Exception Location: /home/pkaramol/Workspace/virtualenvs/time_ds/venv_p34dj18/lib/python3.4/site-packages/bootstrap3_datepicker/fields.py in <module>, line 3
Using python 3.4.3 in the following venv
Django==1.8.11
django-bootstrap3-datepicker==0.3.1
flake8==2.5.4
mccabe==0.4.0
numexpr==2.5
numpy==1.10.4
pep8==1.7.0
pyflakes==1.0.0
requests==2.9.1
tables==3.2.2
When using relative import (.widgets
) another exception occurs:
AttributeError at /
'NoneType' object has no attribute 'replace'
Exception Location: /home/pkaramol/Workspace/virtualenvs/time_ds/venv_p34dj18/lib/python3.4/site-packages/bootstrap3_datepicker/widgets.py in conv_date_format_py2js, line 58
Whenever I read any tutorial on JavaScript or jQuery, this one thing was always included: Put library loading script tags at the end of the document for page load optimization, also use something like
$(document).ready(
// define datepicker activation code here
)
Support for Widget.render() without the renderer argument was removed from Django.
Needed to change to: "def render(self, name, value, attrs=None, renderer=None):" (line 107, file widgets.py)
hi:
it seems you went from version 2.2.3 to 3.0 (according to the readme); could you update that version number in the setup?
thanks!
If I click too many times on the arrow to go back one month, the script hangs on a infinite loop. The issue was reported at least twice on Eonasdan's repository:
Eonasdan/tempus-dominus#199
Eonasdan/tempus-dominus#198
I am using django-bootstrap3-datetimepicker on my site and this issue is affecting me... maybe the bug came along with commit 8aa28a6 ?
Hello, I'm trying to get the datetimepicker to show up with an inlineformset and the fields appear on the formset along with a box where the glyph should be but the glyph is missing & nothing happens when I click within the field. I've included both bootstrap & bootstrap3_datetime in my settings.py file and have added the links to the top of my template but I'm unable to get the calender to popup. I should also mention that I utilize crispy forms as well as JQuery to dynamically create fields. Thus, I believe this may be an issue with one component blocking the other, but am uncertain where the problem lies.
In the newer versions the option language has been renamed to locale, causing problems when rendering the script. I think that the only thing you have to do to solve this issue is change the key 'language' in your widgets.py for 'locale'. At line 103.
Going from this: self.options['language'] = translation.get_language()
to this: self.options['locale'] = translation.get_language()
I'm trying to set a default date mentioned in the options like this, but it is not showing up when displaying the form.
start_time = forms.DateTimeField(
required=True,
widget=DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
"defaultDate": datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),
}))
Am I missing something?
No activity on Pull requests for years and no releases pushed to PyPI recently, and code is completely broken on recent versions of Django. Please comment here if you know of a fork or drop-in replacement. Thanks!
Will there be an update to datepicker v4? Besides, though v2.3 seems to be the stable version I does not seem to be possible to install it via pip.
Are you updating this? If you are, I just released 2.1.30 and if you're interested, I can add some install instructions and a link to your repository.
The problem is this line:
from django.forms.util import flatatt
I believe flatatt
was moved to django.forms.utils
.
It is posibble ?
How use fontawesome ?
regards
Dominik
The current version on PyPI is old. Please upload version 2.3
Thanks and great job!
Hey, really like this project but somehow the options I set get ignored. Any idea where this is coming from?
The form:
class AddWorkTimeForm(ModelForm):
class Meta:
model = WorkTime
fields = ['starting_time', 'absolute_time']
labels = {
'starting_time': _("Starting time (optional)"),
'absolute_time': _("Absolute time (in minutes)")
}
widgets = {
'starting_time': DateTimePicker(options={
'format': "YYYY-MM-DD HH:mm",
'pickSeconds': True,
'startView': 1,
'todayBtn': True,
'forceParse': False,
})
}
template file:
{% extends "task_manager/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load task_filters %}
{% block content %}
<div class="row">
<div class="col-md-6 col-sm-12">
{{ add_working_time_form.media }}
<form class="" role="form" action="{% url "task_manager:detail" task.id %}" method="POST">
{% csrf_token %}
{% bootstrap_form add_working_time_form %}
{% buttons %}
<button type="submit" class="btn btn-success" />
{% trans "Add working time" %}
</button>
{% endbuttons %}
</form>
the produced javascript:
$(function() {
$("#id_starting_time_picker").datetimepicker({"pickSeconds": true, "forceParse": false, "startView": 1, "format": "YYYY-MM-DD HH:mm", "todayBtn": true, "language": "en-us"});
});
But all I see is the default datepicker, with no pickseconds, startview being the view where I can chose the day of the month, forceParse seems to be activated, ...
Really would like to use the widget though and appreciate any help
Hi,
Could you push django-bootstrap3-datetimepicker to PyPi ?
Thanks !
Line 181 (last line in set()) calls hide() when pickTime is false. Why is that?
Btw, looking at the original datetimepicker JS code, I don't see anything similar in set().
IIRC, the actual bootstrap-datetimepicker.js provided here is the version 2.1.30
seems there is a new one: v3.0.0
https://github.com/Eonasdan/bootstrap-datetimepicker/blob/master/src/js/bootstrap-datetimepicker.js
I noticed the v3.0.0 comes with some new method (setMinDate, etc .. see http://eonasdan.github.io/bootstrap-datetimepicker/#example3)
Do you plan to update to the newest version ?
Do you need some help to do it?
BTW, Thanks for your integration in django forms, greatly appreciated!
Hi,
I'm trying to use Bootstrap 3 Datepicker v4 (http://eonasdan.github.io/bootstrap-datetimepicker/).
Using bootstrap3/django1.9/crispy-forms
I found django-bootstrap3-datetimepicker (https://github.com/nkunihiko/django-bootstrap3-datetimepicker).
I'm just really not sure how to use this in crispy forms - would really appreciate a steer, am fairly new to django but my python is "ok".
I'm unsure if it would be better to:
(1) use the java directly in a crispy template attached through the a Field()
(2) somehow attach the widget from the second link/package in the ModelForm
My Layout is set in a ModelForm.
Form is rendered through a class based view.
Anyway, I'm not having much luck at the moment, although I got a bit sidetracked by the "other" bootstrap datetimepicker.
Thanks
:)
PS this is a double post as also asked in the crispy forms git...
If you're using a models.TimeField() and configuring the widget to something like DateTimePicker(options={"format":"HH:mm", "pickDate":False}). Should work.
It does for new objects form, but it does not work for editing an object. It tries to convert the object value to a datetime value, and obviously, that's not possible.
I think this should include some kind of check about if the value is_instance of datetime or time, to make it work in both cases.
I looked in your source code, package bootstrap3_datetime.widgets, you used from django.forms.util import flatatt
But, in django 1.9.7, it must be from django.forms.utils import flatatt
, so, it throw ImportError: No module named util
Django renders the field as "#id_" but JS is looking for "#id__picker". As of Django 1.7.
Hi, I am having this issue with the picker: it displays correctly, but the first time you click on a day, the current date and time appear in the field, instead of the selected value. After this, the field value cannot be changed, no date other than the current one can ever be entered. However, the selection indicator in the picker does change based on clicks. My code in forms.py is:
select_start_date = forms.DateTimeField(label="Select the start date and time for your request",
required=True,
widget=DateTimePicker(options={"format": "YYYY-MM-DD HH:mm",
"pickSeconds": False})
)
And in the html template file the form renders to:
<script type="text/javascript">
$(function () {
$('#id_select_start_date').datetimepicker();
});
</script>
Thanks for any help!
Hi,
I'm a french guy too, and datetimepicker localization doesn't work for me too.
I'm using the picker without customization, and
<script type="text/javascript" src="/static/bootstrap3_datetime/js/locales/bootstrap-datetimepicker.fr.js"></script>
seams loaded, but l10n does not appear in the page, stay in english.
I've tried to copy static/bootstrap3_datetime/js/locales/bootstrap-datetimepicker.fr.js to bootstrap-datetimepicker.fr-fr.js, but same issue.
Thanks for you great work !
Chrome's dev console kept throwing me a nasty error that xxxx.yyy.size()
was not a function. Turns out calls to size()
have been deprecated since JQuery 1.8. Replaced with .length
and it worked perfectly.
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.