We have a generic super model class:
class UUIDObject(models.Model):
id = SimpleUUIDField(primary_key=True, default=uuid.uuid4)
objects = InheritanceManager()
UUIDObject uses InheritanceManager from model_utils and SimpleUUIDField which is a simple specialization of Django's UUIDField with more tolerance regarding string values.
UUIDObject permits retrieval of a model instance by id without having to worry about the model type.
The User model for the app inherits from UUIDObject thus:
from django.contrib.auth.models import AbstractUser, UserManager as DjangoUserManager
from model_utils.managers import InheritanceManager
class UserManager(InheritanceManager, DjangoUserManager):
pass
class User(AbstractUser, UUIDObject):
objects = UserManager()
To preserve development users over re-factors, we keep a fixture of the devs for convenience. This is readily created with e.g django-admin.py dumpdata core.user --indent 2 > devs.json
and the resulting file looks correct. When reloaded with e.g django-admin.py loaddata devs
, the loading of the fixtures is reported as successful but the objects do not get added to the tables. When I use the verbose flag, it indicates that each user record in the fixture is being added twice (that sorta makes sense - one for the root table and one for the dependent table) but no actual entries appear in either table.
It seems that loaddata is just failing silently and reporting success.