django models
Models in Django are classes that represent data base tables.
django models
Models in Django are classes that represent data base tables.
django abstract models
from django.db import models
class CommonInfo(models.Model):
created = models.DateTimeField(auto_now=True)
updated = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['-created']
abstract = True
# table housing the organizations (multiple tenants)
class Tenant(CommonInfo):
name = models.CharField(max_length=255, unique=True)
business_phone_number = models.CharField(max_length=250)
business_email = models.EmailField()
is_active = models.BooleanField(default=True)
schema = models.CharField(max_length=255)
subdomain = models.CharField(max_length=255)
tenant_id = models.SlugField(blank=True)
def __str__(self):
return self.name
# organizational departments db table
class Department(CommonInfo):
name = models.CharField(max_length=255, unique=True)
def __str__(self):
self.name
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us