How to make django textfield required

I'm somehow unable to make the field required, setting null and blank to True has no effect.

# models.py
from django.db import models

class ExampleModel(models.Model):
    text_field = models.TextField()

# tests.py
from django.test import TestCase
from .models import ExampleModel

class ExampleModelTestCase(TestCase):
    def test_text_field_integrity(self):
        with self.assertRaises(Exception):
            example = ExampleModel.objects.create()


Does example.full_clean() work?

cf. reference: http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#django.db.models.Model.full_clean

Вернуться на верх