django-bootstrap-datepicker-plus
django-bootstrap-datepicker-plus copied to clipboard
AttributeError: 'list' object has no attribute 'replace'
I'm trying to use a custom form but I see this error:
File "/home/maxdragonheart/DEV_FOLDER/Django/Enographiae/enographiae_dev/devenv/lib/python3.7/site-packages/bootstrap_datepicker_plus/_base.py", line 91, in init super().init(attrs, self._calculate_format()) File "/home/maxdragonheart/DEV_FOLDER/Django/Enographiae/enographiae_dev/devenv/lib/python3.7/site-packages/bootstrap_datepicker_plus/_base.py", line 107, in _calculate_format self.config['options']['format'] = self.format_py2js(_format) File "/home/maxdragonheart/DEV_FOLDER/Django/Enographiae/enographiae_dev/devenv/lib/python3.7/site-packages/bootstrap_datepicker_plus/_base.py", line 70, in format_py2js datetime_format = datetime_format.replace(py_format, js_format) AttributeError: 'list' object has no attribute 'replace'
This happen when I add format
as option of DateTimePickerInput
. Below a part of my code:
forms.py
publishing_date = forms.DateTimeField(
widget=DateTimePickerInput(
format=['%d/%m/%Y %H:%M'],
),
required=False,
)
mytemplate.html
<form method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
{{ form.as_p }}
<hr>
<div class="row justify-content-md-center">
<div class="col-md-auto">
<input type="submit" class="btn btn-info shadow" value="Pubblica">
</div>
</div>
</form>
How I can put date and time as dd/mm/yyy hh:mm
precisely?
The problem is you are passing a list as format argument. You should pass a single format string.
format='%d/%m/%Y %H:%M'
Thank you! This problem is solved but now I have another problem. I can't change date and time. If I change date and time the post is published only with today date and time.
Closing pre v5 issues as stale.