Year Field in Django : <p>I want my users to enter their birth year. I don't want them to type the same in the form rather select the year from available options. I known that I can do something like this in my model if I needed to date instead of year:</p>

<pre><code>class MyModel(models.Model):

    birthday = models.DateField(null=True, blank=True)
</code></pre>

<p>I can do this in forms to let the user choose date from datepicker.</p>

<pre><code>    birthday = forms.fields.DateField(widget=forms.widgets.DateInput(attrs={'type': 'date'}))
</code></pre>

<p>For year, I can use a <code>CharField/IntegerField</code> with <code>choices</code> similar to what has been done in this <a href="https://stackoverflow.com/a/24656072/8414030">SO</a> answer. </p>

<pre><code>import datetime
YEAR_CHOICES = [(r,r) for r in range(1984, datetime.date.today().year+1)]

year = models.IntegerField(_('year'), choices=YEAR_CHOICES, default=datetime.datetime.now().year)
</code></pre>

<p>The problem, however, is that change of current year from say, 2018 to 2019, will not change the available options.</p>

<p>Can you help or provide hints to achieve what I want to do?</p>
