register and sign in pages
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Atoll(models.Model):
|
||||
name = models.CharField(max_length=100, unique=True)
|
||||
# Maldivian administrative code, e.g. "F" for Faafu.
|
||||
code = models.CharField(max_length=8, blank=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
||||
class Island(models.Model):
|
||||
atoll = models.ForeignKey(Atoll, on_delete=models.PROTECT, related_name="islands")
|
||||
name = models.CharField(max_length=100)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["atoll", "name"], name="unique_island_name_per_atoll"
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name}, {self.atoll.name}"
|
||||
Reference in New Issue
Block a user