cms/cmsMain/models.py
2024-08-13 14:41:25 +03:00

40 lines
No EOL
1.3 KiB
Python

from django.db import models
# Create your models here.
class Page(models.Model):
title = models.CharField("Название",max_length=50)
content = models.TextField("Содержимое")
def __str__(self):
return self.title
class Meta:
verbose_name = "Страница"
verbose_name_plural = "Страницы"
class Site(models.Model):
domain = models.CharField("Домен",max_length=50)
base_page = models.ForeignKey(Page,on_delete=models.PROTECT,verbose_name="Базовая страница")
def __str__(self) -> str:
return self.domain
class Meta:
verbose_name = "Сайт"
verbose_name_plural = "Сайты"
class Url(models.Model):
site = models.ForeignKey(Site,on_delete=models.PROTECT,verbose_name="Сайт")
path = models.CharField("Путь",max_length=50)
page = models.ForeignKey(Page,on_delete=models.PROTECT,verbose_name="Страница")
def __str__(self):
return f"{self.site.domain}/{self.path}"
class Meta:
verbose_name="Ссылка"
verbose_name_plural="Ссылки"
class Variable(models.Model):
name = models.CharField("Имя",max_length=50)
value = models.TextField("Значение")
def __str__(self):
return self.name
class Meta:
verbose_name = "Переменная"
verbose_name_plural = "Переменные"