Given a set of typical models:
# Application A
from django.db import models
class TypicalModelA(models.Model):
the_date = models.DateField()
# Applicat
Well, making a custom model field just to change it's default form widget is not really the obvious place to start.
You can make your own form widget and override the field in the form, specifying your own widget like in Soviut's answer.
There's also a shorter way:
class ArticleForm(ModelForm):
pub_date = DateField(widget=MyDateWidget())
class Meta:
model = Article
There is an example of how to write form widgets, it's somewhere in the forms package of Django. It's a datepicker with 3 dropdowns.
What I usually do when I just want to add some JavaScript to a standard HTML input element is leave it the way it is and modify it by referencing it's id later with JavaScript. You can easily catch the naming convention for the ids of the input fields Django generates.
You can also just provide the class for the widget when you override it in the form. Then catch them all with jQuery by the class name.