> > The ModelFormMetaclass usage you suggest is not supported by Django at > this point
Sorry if I was unclear, I meant something like this (untested): class MyModelFormMetaclass(ModelFormMetaclass): """ Customize the way our forms get built """ def __new__(*args, **kwargs): new_class = super(MyModelFormMetaclass, self).__new__(*args, **kwargs) for name in list(new_class.base_fields): field = new_class.base_fields[name] if should_fixup(field): new_class.base_fields[name] = fixup_field(field) return new_class class MyModelForm(six.with_metaclass(ModelFormMetaclass, BaseModelForm)): pass I understand it's not so general purpose as to allow you to edit the forms in third party apps, but it can be done today with current Django, and you could fork the third party app so it imports MyModelForm. On 23 December 2016 at 11:32, James Pic <james...@gmail.com> wrote: > Thanks a lot for your time and quick answer Adam ! The ModelFormMetaclass > usage you suggest is not supported by Django at this point. Suggesting that > doing it is easy and supported seems incorrect in my experience, starting > with the fact that there is no documentation. > > There are a lot of problems out there with imaginary third party apps that >> you want to modify the internals of :) >> > > I have to disagree here, it's perfectly supported to override the apps > views, forms and admins to change a widget: when it's done right it works. > It's just a lot of error-prone and manual work and I wish Django proposed a > way to reduce the cost of this. > > In my experience, it works fine to enhance one app with the widget > provided by another. As demonstrated, it's already possible, but the cost > of 6 steps is something I'd like to reduce to one, DRY step. > > >> Often it's not hard to get third party apps to add some hook for >> extension (e.g. their own setting, or signal, ...) or to fork it yourself - >> easier than modifying Django core. >> > > I don't understand why the community would be against reducing the cost of > using a form field or widget of an app to enhance another: given the number > of apps which provide just a form field or widget, I can hardly believe I'm > the only one to do this kind of things. I mean, are we formfield/widget app > maintainers so ahead time for maintaining such apps ? > > I'm really sorry that I couldn't make it clear that we need a way to > "overriding the default form field generator ***mechanism***", and that > answers that were given to me are about just "overriding a form field", > similarly to the hundreds of StackOverflow answers and countless number of > blog posts I've published on this subject myself. > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at https://groups.google.com/group/django-developers. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-developers/CALC3KacjBh8XO09cStzAvRbSCdcuJ > n8Wd-CWZp26LuejMFMrZw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-developers/CALC3KacjBh8XO09cStzAvRbSCdcuJn8Wd-CWZp26LuejMFMrZw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Adam -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3Mjo2DYXshdAYP6eDXuidDQg16jSYfbMK9niQMDiDczA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.