class RegionsModel(models.Model):
name = models.CharField(max_length=64,
unique=True, )
def __unicode__(self):
return self.name
class DetachmentsModel(models.Model):
region = models.ForeignKey('RegionsModel',
on_delete=models.CASCADE,
related_name='region_children', )
name = models.CharField(max_length=64,
unique=True,
db_index=True)
def __unicode__(self):
return self.name
class DepartmentsModel(MPTTModel):
detachment = models.ForeignKey('DetachmentsModel',
on_delete=models.CASCADE,
related_name='detachment_children', )
name = models.CharField(max_length=64,
unique=True,
db_index=True, )
slug = models.SlugField(max_length=64,
unique=True,
primary_key=True, )
def __unicode__(self):
return self.name