On Mon, Mar 16, 2009 at 1:32 AM, Tai Lee <[email protected]> wrote:
> > The re-factored code moves the definition of default widgets for each > model field into an update-able dict and uses `if dbfield.__class__ in > self.formfield_overrides` to look up the correct widget for `dbfield` > instead of using `isinstance()`. > > The problem arises when using a custom model field that is subclassed > from Django model field, for example a custom DateTimeField which uses > international input formats by default with the idea being the user > can avoid specifying input formats everywhere the DateTimeField is > used (including Django's admin) without needing to customise their > ModelAdmin and ModelForm classes. > > I thought that the solution would be to change `if dbfield.__class__ > in self.formfield_overrides` to a for loop that checks for a match > with `isinstance()` on each iteration. The problem with this approach > is that some Django model fields already subclass others (e.g. > CharField) and if a user also wants to add their own widget mapping to > their custom field. With `formfield_overrides` being a dict we can't > be sure of the order we'd be looping over it, and the order would be > important (e.g. check for subclassed fields before base/parent > fields). > > Another alternative might be that if a user wants to create a custom > model field and have it use an existing widget or their own widget, > they'll need to add to `formfield_overrides` themselves, but I'm not > sure if this would defeat the purpose of not repeating yourself given > the example above. > > I haven't created a ticket for this yet, but discovered it while > digging for an explanation of #8898. Does anyone have feedback or > suggestions? > > Cheers. > Tai. > > http://code.djangoproject.com/ticket/8898 > > > > > There's already a ticket for this(#10059) http://code.djangoproject.com/ticket/10059 and it has a patch that should solve this issue. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
