2024-08-11 22:39:47 +03:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
# Create your models here.
|
|
|
|
|
|
|
|
class Page(models.Model):
|
2024-08-13 14:41:25 +03:00
|
|
|
title = models.CharField("Название",max_length=50)
|
2024-08-11 22:39:47 +03:00
|
|
|
content = models.TextField("Содержимое")
|
2024-08-13 14:41:25 +03:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
2024-08-11 22:39:47 +03:00
|
|
|
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 = "Сайт"
|
2024-08-13 14:41:25 +03:00
|
|
|
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 = "Переменные"
|