Given a set of typical models:
# Application A
from django.db import models
class TypicalModelA(models.Model):
the_date = models.DateField()
# Application B
from django.db import models
class TypicalModelB(models.Model):
another_date = models.DateField()
...
How might one change the default widget for all DateFields to a custom MyDateWidget?
I'm asking because I want my application to have a jQueryUI datepicker for inputting dates.
I've considered a custom field that extends django.db.models.DateField with my custom widget. Is this the best way to implement this sort of across-the-board change? Such a change will require specifically importing a special MyDateField into every model, which is labour intensive, prone to developer error (i.e. a few models.DateField's will get through), and in my mind seems like unnecessary duplication of effort. On the other hand, I don't like modifying what could be considered the canonical version of models.DateField.
Thoughts and input is appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…