Django documentation

Empty model tests

This example describes Django version 0.95. For the current example, go here.

These test that things behave sensibly for the rare corner-case of a model with no fields.

Model source code

from django.db import models

class Empty(models.Model):
    pass

API_TESTS = """
>>> m = Empty()
>>> m.id
>>> m.save()
>>> m2 = Empty()
>>> m2.save()
>>> len(Empty.objects.all())
2
>>> m.id is not None
True

"""