class Contacts(models.Model):
PHONE = '<a href="tel:'
TEXT = 'текст'
MAIL = '<a href="mailto:'
LINK = '<a href='
TYPE_CHOICES = [
(PHONE, 'телефон'),
(TEXT, 'текст'),
(MAIL, 'почта'),
(LINK, 'ссылка'),
]
type = models.CharField(
max_length=50,
choices=TYPE_CHOICES,
)
content = models.CharField(max_length=200)
url_text = models.CharField(max_length=200, blank=True, null=True)
@property
def get_full(self):
if self.type == self.TEXT:
startstr = ""
closetag = ""
endstr = ""
url_text = ""
else:
startstr = self.type
closetag = "\">"
endstr = "</a>"
url_text = self.url_text
test = f"{startstr}{self.content}{closetag}{url_text}{endstr}"
return test
def __str__(self):
return f"{self.content}"
THOROUGHBRED = 'TH', 'Породистая'
CROSSBREED = 'CR', 'Помесь'
NOBREED = 'NO', 'Без породы'
class Dog(models.Model):
"""Собаки"""
Horoughnredness = [
('TH', 'Породистая'),
('CR', 'Помесь'),
('NO', 'Без породы'),
]
breed_type = models.CharField(
max_length=12,
choices=Horoughnredness,
)
name = models.CharField(max_length=200, db_index=True)
def __str__(self):
return self.name