right-tree/backend/right_tree/api/views.py
Dana Lambert 12ebe31cf5 Add coordinate filter on the backend
- filters plants based on ecological region and soil order
2021-10-19 16:06:21 +13:00

21 lines
No EOL
684 B
Python

from rest_framework import viewsets
from right_tree.api.models import Plant
from right_tree.api.serializers import PlantSerializer
from .filters import coordinate_filter
class PlantViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows hours to be grouped or edited.
"""
queryset = Plant.objects.all()
serializer_class = PlantSerializer
def get_queryset(self):
""" Filtering plant query set by query parameters in the URL.
(May want to eventually use django filters to break up the logic...)
"""
queryset = Plant.objects.all()
queryset = coordinate_filter(self.request, queryset)
return queryset