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?
the ModelForm is a Form then you can do
class ServerForm(ModelForm):
    class Meta:
        model = Server
    def clean_name(self):
        """ Define a method to check the name field """
    def clean(self):
        """ Define a clean method for all the form """
without problem
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论