add faq section
This commit is contained in:
@@ -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}"
|
||||
@@ -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
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user