Files
api.digisnaxx/leg_info/views.py

29 lines
1008 B
Python
Raw Normal View History

2025-10-11 03:50:49 -05:00
from django.shortcuts import render
from datetime import datetime, timedelta
import pytz
from .models import *
from .serializers import *
from django.db.models import Q
from rest_framework import generics
from rest_framework.decorators import authentication_classes, permission_classes
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.permissions import IsAuthenticated
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
td = timedelta(hours=8)
odt = datetime.now() - td
# Create your views here.
@permission_classes([])
@authentication_classes([])
class EventsAPIView(generics.ListAPIView):
serializer_class = EventSerializer
queryset = Event.objects.filter(show_date__gte=odt).order_by('show_date')
filter_backends = [DjangoFilterBackend, filters.SearchFilter]
filterset_fields = ['show_title', 'event_type', 'show_date', 'show_day']
search_fields = ['show_title', 'event_type']