by cma · 13y ago · 0 comments
from django.db import models
+from django.core.exceptions import ValidationError
+def not_empty(value):
+ if value == u'': raise ValidationError(u'Empty value')
class MyModel(models.Model):
- name = models.CharField(max_length=50, blank=True)
+ name = models.CharField(max_length=50, blank=True, validators=[not_empty])https://docs.djangoproject.com/en/dev/ref/models/fields/#bla...