views:

25

answers:

0

I am developing an app for use on Google App Engine with Django and Google App Engine Django Helper.

A certain model is looking like this:

from appengine_django.models import BaseModel
from google.appengine.ext import db
from google.appengine.ext.db.djangoforms import ModelForm

class Server(BaseModel):
    name = db.StringProperty(required=True)
    ip = db.StringProperty()
    status_ok = db.BooleanProperty(default=False)

    def __unicode__(self):
        return self.name

class ServerForm(ModelForm):
    class Meta:
        model = Server

How can I add a custom validator (for example a minimum and maximum length for a string) to this code so that the form.is_valid() method will act accordingly?