#26369: Allow override of hardcoded defaults in model Field.formfield()
--------------------------------------+--------------------
     Reporter:  jpic                  |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  Forms                 |    Version:  1.9
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 Currently, the model field defines the default form field that's used
 by the modelform metaclass. It would be nice if we could override this.

 For example, if a Radio widget should be used by default for a OneToOne
 field:

 {{{
     class TestModel(models.Model):
         name = models.CharField(max_length=200)

         test = models.OneToOneField(
             'self',
             null=True,
             blank=True,
             related_name='related_test_models',
             # This seems like it would always be useful
             formfield_defaults={
                 'widget': forms.RadioSelect
             }
         )
 }}}

 Example (incomplete) patch:
 https://github.com/jpic/django/commit/d102f362f3c1ceaf2d5224d71f788c0821a481ae

--
Ticket URL: <https://code.djangoproject.com/ticket/26369>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/047.cba8cb004ef78e84060cfac731b2a7ce%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to