djangosnippets.org: Latest snippets tagged with 'month'http://djangosnippets.org/tags/month/2022-09-07T07:45:58.340688-05:00Month / Year SelectDateWidget based on django SelectDateWidget
2022-09-07T07:45:58.340688-05:00pierrebenhttp://djangosnippets.org/snippets/10943/<p>A more simple version of <a href="https://djangosnippets.org/snippets/1688/">https://djangosnippets.org/snippets/1688/</a>, inheriting from <code>SelectDateWidget</code>, overriding only the necessarily. </p>
<p><strong>Usage example:</strong></p>
<p><strong>In models.py:</strong></p>
<pre><code>from django.db import models
from django.utils.translation import gettext_lazy as _
class MyModel(models.Model):
start = models.DateField(
_("Start date"),
)
end = models.DateField(
_("End date"),
)
class Meta:
verbose_name = _("My model")
</code></pre>
<p><strong>In …</strong></p>
Freely redistributableMonth / Year dropdown widget Python 3 compatible
2015-08-20T10:56:59.850004-05:00pxghttp://djangosnippets.org/snippets/10522/<p>Python 3 version of https://djangosnippets.org/snippets/1688/</p>
Freely redistributableSelectDateWidget with format: day, month, year
2009-12-13T05:08:59.428738-06:00zenxhttp://djangosnippets.org/snippets/1834/<p>This is the same as <a href="http://code.djangoproject.com/browser/django/trunk/django/forms/extras/widgets.py#L16">django.forms.extras.widgets.SelectDateWidget</a> but changing the order of the rendered select boxes to: day, month, year.</p>
Freely redistributableMonth / Year dropdown widget
2009-08-16T17:41:03.643422-05:00gregbhttp://djangosnippets.org/snippets/1688/<p>This is an adaption of </p>
<p><a href="http://code.djangoproject.com/browser/django/trunk/django/forms/extras/widgets.py#L16">django.forms.extras.widgets.SelectDateWidget</a></p>
<p>which has no day dropdown - it still produces a date but with the day set to 1.</p>
<p>Example use</p>
<pre><code>class myForm(forms.Form):
# ...
date = forms.DateField(
required=False,
widget=MonthYearWidget(years=xrange(2004,2010))
)
</code></pre>
Freely redistributable