from django.db import models class Tenant(models.Model): """ Tenant model for multi-tenancy support. Each tenant represents a separate business unit or organization. """ name = models.CharField(max_length=200, unique=True) subdomain = models.SlugField(max_length=100, unique=True) schema_name = models.CharField(max_length=100, unique=True) is_active = models.BooleanField(default=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) # Tenant-specific configurations company_name = models.CharField(max_length=200, blank=True) contact_email = models.EmailField() phone_number = models.CharField(max_length=15, blank=True) website = models.URLField(blank=True) # Branding settings logo = models.ImageField(upload_to='tenant_logos/', null=True, blank=True) primary_color = models.CharField(max_length=7, default='#007bff') # Hex color secondary_color = models.CharField(max_length=7, default='#6c757d') # Hex color # Feature flags enable_social_login = models.BooleanField(default=True) enable_email_notifications = models.BooleanField(default=True) def __str__(self): return self.name class Meta: verbose_name = 'Tenant' verbose_name_plural = 'Tenants'