#30077: TextField constructor needs a strip=False option
-------------------------------------+-------------------------------------
               Reporter:  Rob van    |          Owner:  nobody
  der Linde                          |
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  2.1
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In Django 1.9 an option strip=True was added to CharField, this is fine
 but it also seems to affect TextField and there is no way to pass a
 strip=False option to TextField constructor to turn that off.

 The issue seems to be the formfield method, this has lead to people
 subclassing TextField to "fix" this addition to Django 1.9, for example:

 {{{
 class NonStrippingTextField(TextField):
     """A TextField that does not strip whitespace at the beginning/end of
     it's value.  Might be important for markup/code."""

     def formfield(self, **kwargs):
         kwargs['strip'] = False
         return super(NonStrippingTextField, self).formfield(**kwargs)

 }}}

 Other people fix it in the form and override the admin form, this has
 become a bit messy, it seems to be necessary to introduce a strip argument
 to the TextField constructor, to avoid having to create custom field
 types.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30077>
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.078f82278dfc712e95d9f2f54a82ccb2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to