---
# System prepended metadata

title: Примеры структуры БД в Django

---

# Примеры структуры БД в Django


# Пользователь
```

username = None

email = models.EmailField()

first_name_translated = models.CharField("Транслит имени", max_length=100, blank=True)

last_name_translated = models.CharField("Транслит фамилии", max_length=100, blank=True)

middle_name = models.CharField("Отчество", max_length=100, blank=True)

middle_name_translated = models.CharField("Транслит отчетства", max_length=100, blank=True)

date_of_birth = models.DateField("День рождения", null=True)

sex = models.CharField("Пол", max_length=10, choices=Sex.choices)
    
phone_number = models.CharField("Номер телефона", max_length=40, blank=True)
    
status = models.CharField(
        verbose_name="Статус",
        max_length=60,
        choices=Status.choices,
        default=Status.NEW
)

role = models.CharField(
        "Роль",
        max_length=60,
        choices=Role.choices,
        default=Role.USER
)

level = models.CharField(
        verbose_name="Уровень",
        max_length=50,
        choices=Level.choices,
        default=Level.STUDENT
)
    
image = models.ImageField(
        verbose_name="Изображение пользователя",
        upload_to=get_user_image_path,
        default="user/images/no-image.png",
        blank=True
)
```


# Новость

slug = models.SlugField(
        unique=True,
    )
    
tags = models.ManyToManyField(
        Tag,
        through='NewTag',
        verbose_name="Теги новостей"
)

title = models.CharField(
        verbose_name='загаловок',
        max_length=255
)
    
seo_title = models.CharField(
        max_length=255,
        verbose_name='SEO загаловок',
        default=''
)

seo_description = models.CharField(
        max_length=1250,
        verbose_name='SEO описание',
        default=''
)

heading = models.CharField(
        verbose_name='рубрика',
        max_length=255
)
    
created_at = models.DateField(
        auto_now_add=True,
        verbose_name='дата публикации',
)
    
banner = models.FileField(
        upload_to='NewBanners/',
        verbose_name='баннер новости',
        blank=True
)

relevance = models.BooleanField(
        verbose_name='Актальность',
        default=False
)
    
short_description = models.TextField(
        verbose_name='краткое описание журнала',
        default=''
)
    
views = models.IntegerField(
        default=0,
        verbose_name='просмотры'
)
    
description = models.TextField(
        verbose_name='описние новости'
)
    
soft = models.CharField(
        max_length=255,
        verbose_name='софт',
        blank=True
)
    
year = models.CharField(
        max_length=255,
        verbose_name='год выпуска',
        default="2022"
)
    
comments = models.ManyToManyField(
        Comment,
        through='NewComment',
        verbose_name='комментарии новости'
)
    
rating = models.ManyToManyField(
        Reviews,
        through='NewReviews',
        verbose_name='отзывы новости'
)