From 2c3470578bfcedf6d8a93319f2504819894694f0 Mon Sep 17 00:00:00 2001 From: "nabijonovdavronbek619@gmail.com" Date: Mon, 12 Jan 2026 11:43:40 +0500 Subject: [PATCH] add faq section --- content/models.py | 10 ++++++++++ content/urls.py | 3 ++- content/views.py | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/content/models.py b/content/models.py index 1c03f08..8064336 100644 --- a/content/models.py +++ b/content/models.py @@ -38,3 +38,13 @@ class ContactMessage(models.Model): def __str__(self): return f"Message from {self.name}" + +# ======== FAQ MODEL ======== +class FAQ(models.Model): + question_uz = models.CharField(max_length=255) + question_ru = models.CharField(max_length=255) + answer_uz = models.TextField() + answer_ru = models.TextField() + + def __str__(self): + return f"FAQ: {self.question_uz}" \ No newline at end of file diff --git a/content/urls.py b/content/urls.py index 3353ba4..e7e1213 100644 --- a/content/urls.py +++ b/content/urls.py @@ -1,11 +1,12 @@ from django.conf import settings from django.conf.urls.static import static from django.urls import path -from .views import get_products, create_contact +from .views import get_products, create_contact , get_faqs urlpatterns = [ path('products/', get_products), # GET path('contact/', create_contact), # POST + path('faqs/', get_faqs), # GET ] diff --git a/content/views.py b/content/views.py index 60ea795..6b68157 100644 --- a/content/views.py +++ b/content/views.py @@ -23,3 +23,13 @@ def create_contact(request): return Response({"success": True}, status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + +# --- GET FAQS --- +@api_view(['GET']) +def get_faqs(request): + from .models import FAQ + from .serializers import FAQSerializer + + faqs = FAQ.objects.all() + serializer = FAQSerializer(faqs, many=True) + return Response(serializer.data, status=status.HTTP_200_OK)