I want to mention what I consider to be a usability issue with Django
forms. It has to do with there being no option to strip leading and
trailing whitespace from CharFields, URLFields, EmailFields, etc.
Ticket #4969 was to address this issue but was closed with as a
'wontfix', and I have seen other discussions on this issue.
It's easier and quicker to locally extend Django.
Here's the start of my forms extension. It has all the form goodness I
want and in my forms.py I do a
from myforms import *
from django import newforms as forms
from django.newforms import ModelForm
from django.newforms.models import ModelChoiceField,
ModelMultipleChoiceField
from django.contrib.localflavor.us.forms import USPhoneNumberField
from django.newforms.fields import *
from django.newforms.widgets import *
import django.newforms.fields
import django.newforms.widgets
__all__ = ["StrippedCharField",]
__all__.extend(["forms", "ModelForm", "ModelChoiceField",
"ModelMultipleChoiceField", "USPhoneNumberField"])
__all__.extend(django.newforms.fields.__all__)
__all__.extend(django.newforms.widgets.__all__)
class StrippedCharField(CharField):
"""Newforms CharField that strips trailing and leading spaces."""
def clean(self, value):
if value is not None:
value = value.strip()
return super(StrippedCharField, self).clean(value)
--
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___________________________________________________________________________
You've got fun! Check out Austin360.com for all the entertainment
info you need to live it up in the big city!