from django.contrib.auth.models import AbstractUser from django.db import models class User(AbstractUser): timezone = models.CharField(max_length=64, default="UTC") created_at = models.DateTimeField(auto_now_add=True) class SetupLock(models.Model): """Singleton row that gates first-run setup against a race between concurrent requests. The setup view always tries to INSERT the row with pk=1 in the same transaction as creating the first admin user: the database's primary-key uniqueness makes exactly one of those INSERTs win even under concurrent requests, so only one admin account can ever be created this way, instead of the User.objects.exists() check alone (which has a window between the check and the save).""" id = models.PositiveSmallIntegerField(primary_key=True, default=1)