Skip to content

Commit

Permalink
Make it possible to filter endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort committed Jun 5, 2024
1 parent c3ed4f0 commit 863187c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ class BarViewSet(viewsets.ModelViewSet):
queryset = Bar.objects.all()
serializer_class = BarSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
filterset_fields = ['name', 'description', 'day', 'start_time', 'end_time', 'open', 'tags']


class EventViewSet(viewsets.ModelViewSet):
queryset = Event.objects.all()
serializer_class = EventSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
filterset_fields = ['name', 'description', 'bar', 'start_date', 'end_date']
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ django-nested-admin
Pillow # For ImageField
djangorestframework
drf-spectacular
django-filter
# See https://github.com/zelenij/django-bootstrap-v5/issues/33
git+https://github.com/math-a3k/django-bootstrap-v5.git@9d9f01988f0554028c0fd276939fc1336f0fa997#egg=django-bootstrap-v5

4 changes: 4 additions & 0 deletions studibars/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"django_filters",
"drf_spectacular",
]

Expand Down Expand Up @@ -142,4 +143,7 @@

REST_FRAMEWORK = {
'DEFAULT_SCHEMA_CLASS': 'drf_spectacular.openapi.AutoSchema',
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
),
}

0 comments on commit 863187c

Please sign in to comment.