django-nonrel/django-nonrel — Issue #6: Enforcing Model CharField limitations (GAE)
Author: kensaggy
Created: 2012-01-29 12:40:58+00:00
State: open

Not sure if this is a django-nonrel isssue or a vanilla django issue, but it seems CharField limitation enforcing isn't happening.

On GAE (dev server)..
Here's a test model with a single charfield limited to max_length=1

```python

class TestModel(models.Model):
GENDER_CHOICES = (
(u'M', _('Male')),
(u'F', _('Female')),
)

gender = models.CharField(max_length=1, null=True, choices= GENDER_CHOICES, blank=True)

def __unicode__(self):
return "I am a %s" % self.gender

```

Running in the manage.py shell:

```python
>>> from testapp.models import TestModel
>>> o = TestModel.objects.create(gender=u'M')
>>> o.save()
>>> o

>>> b = TestModel.objects.get(gender=u'M')
>>> b

>>> b.gender=u'male'
>>> b.save()
>>> b

```

the model allows me to insert any amount of text into the CharField even though it is limited to maximum of 1 char
The GAE data store viewer shows the text was saved successfully.

Where are the field limits enforced?

Thanks,
Ken.