I replied to your comment on pr 5123 on github [1] but it seems to be
buried under "Show outdated diff" so here it is again:

I agree that as_text() and as_textarea() are not needed so I will remove
them from the docs.

There is a use case for as_widget() though. In one of my projects I have
a template filter that is called add_class and I use it like this:

{{ my_form.my_field|add_class:'class-added-to-input-field' }}

It uses the attrs argument to as_widget() to easily add the class
attribute. That wouldn't be possible like that if the code was just
private inside __str__().
Although this use case may be invalidated by the upcoming template based
widget rendering.

I'm not sure about as_hidden(). I personally never used it, since you
can easily emulate it with html_name but I'm sure there are a few people
using it.


[1] https://github.com/django/django/pull/5123#discussion_r37645967


Am 21.08.2015 um 17:34 schrieb Tim Graham:
> While reviewing the proposed documentation for BoundField, I noticed the
> methods BoundField.as_textarea() and as_text() [1] introduced at the
> start of new forms [2]. According to the comment, their purpose is as
> "shortcuts for changing the output widget type". These methods aren't
> documented, and I don't think they should be preferred over specifying
> the widget on the form. Any objection to deprecating them? Same applies
> to as_hidden(), except that it's used by BoundField elsewhere, so we
> can't remove it. We could add an underscore prefix to show that it's
> "private", but I don't see much advantage to this.
> 
> [1]
> https://github.com/django/django/blob/d3bc86ec11bb22f06b5e30fac891ef3e43f82a6d/django/forms/forms.py#L587-L601
> [2]
> https://github.com/django/django/commit/4d596a1f6443eaf5d18d70a18aaac25030c7fc81#diff-de8d446d202490f4ac045923ad6fcfb7R98
> 
> On Thursday, August 13, 2015 at 6:36:34 PM UTC-4, Preston Timmons wrote:
> 
>         Yes I know that you can access the Field instance but it
>         wouldn't be
>         possible to do {{ field.field.city }} since a Field is not
>         supposed to
>         have any data stored with it.
> 
> 
>     This makes sense to me. Feel free to make a ticket and attach your
>     PR once it's ready for review.
> 
>     Preston
> 
> -- 
> You received this message because you are subscribed to a topic in the
> Google Groups "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-developers/-Bbi8vg5c9s/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> 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/67f69d17-fb9a-472d-8d5b-fb5ba8f11c8d%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/67f69d17-fb9a-472d-8d5b-fb5ba8f11c8d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/55D74670.1070704%40googlemail.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: OpenPGP digital signature

  • 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