Skip to content

Commit

Permalink
В приложении general создала модель текстовых элементов главной страницы
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadya2502 committed Feb 9, 2024
1 parent 2d2f957 commit 5d06cce
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/backend/apps/general/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GeneralConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.general"
36 changes: 36 additions & 0 deletions src/backend/apps/general/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 5.0.1 on 2024-02-08 22:41

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(),
]

operations = [
migrations.CreateModel(
name="Section",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"title",
models.TextField(max_length=55, verbose_name="Заголовок"),
),
(
"description",
models.TextField(max_length=160, verbose_name="Текст"),
),
],
),
]
Empty file.
14 changes: 14 additions & 0 deletions src/backend/apps/general/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ class CreatedModifiedFields(models.Model):

class Meta:
abstract = True


class Section(models.Model):
"""Секции на главной странице"""

title = models.TextField(
verbose_name="Заголовок", max_length=55, null=False
)
description = models.TextField(
verbose_name="Текст", max_length=160, null=False
)

def __str__(self):
return self.title
9 changes: 9 additions & 0 deletions src/backend/apps/general/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import serializers

from .models import Section


class SectionSerializer(serializers.ModelSerializer):
class Meta:
model = Section
fields = "__all__"
9 changes: 9 additions & 0 deletions src/backend/apps/general/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from rest_framework import generics

from .models import Section
from .serializers import SectionSerializer


class SectionAPIList(generics.RetrieveAPIView):
queryset = Section.objects.all()
serializer_class = SectionSerializer

0 comments on commit 5d06cce

Please sign in to comment.