Here is a ticket for making BoundField a public API: 
https://code.djangoproject.com/ticket/12856
Writing that documentation seems like a good place to start.

I would suggest not to move around so much code in your branch as that 
makes it difficult to tell what (if anything) has changed.

On Saturday, August 8, 2015 at 7:34:52 AM UTC-4, Moritz S. wrote:
>
> Hello, 
>
> I'd like to propose a new feature for forms. 
>
> Currently if you need a form field with some extra features you can just 
> subclass from django.forms.Field and add all the features you need. 
>
> However as soon as you're in a template and want to access the field you 
> will get a BoundField instead of your custom field. The need to 
> differentiate BoundField and Field is clear but it would be nice if it 
> was possible to also customize BoundField. 
>
> For this reason I propose adding a new method "bind_to_form()" to 
> django.forms.Field. It takes a form and a name and returns a BoundField 
> specific to the Field instance. The default implementation just returns 
> an instance of the existing BoundField but now it is possible to 
> customize it. 
>
> To make it easier, BoundField should become public API. That means it 
> should be able to import it with "from django.forms import BoundField" 
> in order to subclass it. 
>
> In [1] you can see an implementation of bind_to_form(). 
> I also wrote BoundChoiceField as an example that allows better access to 
> the choices. In [2] you can see how this could be used. 
>
> Considering BoundField wasn't really public before, this change 
> shouldn't bring any backwards incompatibilities since the default 
> behaviour stays the same. In my test branch all tests pass. 
>
> I'd really like to hear your feedback on this. 
> If this sounds reasonable I will start writing documentation and 
> possibly drafting a DEP if that's needed. 
>
> Moritz 
>
> [1]: https://github.com/MoritzS/django/tree/bound-fields 
> [2]: https://gist.github.com/MoritzS/7bd792f2eaf37da28dfb 
>
>

-- 
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 http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/30c1bf2d-3e15-4f9a-b494-d688f54a4a0b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • A... 'Moritz Sichert' via Django developers (Contributions to Django itself)
    • ... Tim Graham
      • ... 'Moritz Sichert' via Django developers (Contributions to Django itself)
        • ... Tim Graham
          • ... Preston Timmons
            • ... 'Moritz Sichert' via Django developers (Contributions to Django itself)
              • ... Tim Graham
                • ... 'Moritz Sichert' via Django developers (Contributions to Django itself)
                • ... Preston Timmons
                • ... Tim Graham
                • ... 'Moritz Sichert' via Django developers (Contributions to Django itself)

Reply via email to