This Continuation How do I change the default widget for all Django date fields in ModelForm? .
Suppose you have a very large number of models (for example, A-ZZZ) that grow with other developers that are beyond your control, and you want to change the way you enter all the date fields (for example, using jQueryUI). What is the best way to ensure that all date fields are populated with this new widget?
One of the suggested questions:
def make_custom_datefield(f): if isinstance(f, models.DateField):
However, is this possible when you do not have an explicit ModelForm, but url patterns are taken from models directly? those. your url configuration makes sense:
url(r'^A/?$', 'list_detail.object_list', SomeModelA)
where SomeModelA is a model (not a form) that turned into a ModelForm by Django in the background.
There are currently no Forms for each model in my system. The only time you create forms would obviously be to add formfield_callback, as proposed in the previous solution, but this is contrary to DRY principles and will be error-prone and time-consuming.
I considered (as suggested in the last thread) the creation of my own field, which has a special widget and uses it instead of the built-in one. This is not so time consuming, but it can be error prone (nothing could fix a good grep).
Suggestions and thoughts are welcome.
source share