diff --git a/src/backend/apps/general/apps.py b/src/backend/apps/general/apps.py new file mode 100644 index 0000000..b7fc242 --- /dev/null +++ b/src/backend/apps/general/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class GeneralConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "apps.general" diff --git a/src/backend/apps/general/migrations/0001_initial.py b/src/backend/apps/general/migrations/0001_initial.py new file mode 100644 index 0000000..28c44cc --- /dev/null +++ b/src/backend/apps/general/migrations/0001_initial.py @@ -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="Текст"), + ), + ], + ), + ] diff --git a/src/backend/apps/general/migrations/__init__.py b/src/backend/apps/general/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/apps/general/models.py b/src/backend/apps/general/models.py index 84dce68..725695c 100644 --- a/src/backend/apps/general/models.py +++ b/src/backend/apps/general/models.py @@ -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 diff --git a/src/backend/apps/general/serializers.py b/src/backend/apps/general/serializers.py new file mode 100644 index 0000000..4e1a463 --- /dev/null +++ b/src/backend/apps/general/serializers.py @@ -0,0 +1,9 @@ +from rest_framework import serializers + +from .models import Section + + +class SectionSerializer(serializers.ModelSerializer): + class Meta: + model = Section + fields = "__all__" diff --git a/src/backend/apps/general/views.py b/src/backend/apps/general/views.py new file mode 100644 index 0000000..07c50de --- /dev/null +++ b/src/backend/apps/general/views.py @@ -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