Ajout de l'API pour les événements
This commit is contained in:
parent
89904e25ab
commit
296476ebf4
7
src/agenda_culturel/serializers.py
Normal file
7
src/agenda_culturel/serializers.py
Normal file
@ -0,0 +1,7 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Event
|
||||
|
||||
class EventSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = '__all__'
|
@ -65,8 +65,19 @@ INSTALLED_APPS = [
|
||||
"template_profiler_panel",
|
||||
'django_cleanup.apps.CleanupConfig',
|
||||
'django_unused_media',
|
||||
'rest_framework',
|
||||
]
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
# Use Django's standard `django.contrib.auth` permissions,
|
||||
# or allow read-only access for unauthenticated users.
|
||||
"DEFAULT_PERMISSION_CLASSES": [
|
||||
"rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly",
|
||||
]
|
||||
}
|
||||
|
||||
HONEYPOT_FIELD_NAME = "alias_name"
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
@ -3,6 +3,7 @@ from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import path, include, re_path
|
||||
from .views import EventListAPIView
|
||||
from django.views.i18n import JavaScriptCatalog
|
||||
from django.contrib.sitemaps.views import sitemap
|
||||
from django.contrib.sitemaps import GenericSitemap
|
||||
@ -238,6 +239,7 @@ urlpatterns = [
|
||||
name="cached-sitemap",
|
||||
),
|
||||
path("cache/clear", clear_cache, name="clear_cache"),
|
||||
path('api/events/', EventListAPIView.as_view(), name='event-list-api'),
|
||||
|
||||
]
|
||||
|
||||
|
@ -2478,4 +2478,11 @@ def clear_cache(request):
|
||||
return render(
|
||||
request,
|
||||
"agenda_culturel/clear_cache.html",
|
||||
)
|
||||
)
|
||||
|
||||
from rest_framework import generics
|
||||
from .serializers import EventSerializer
|
||||
|
||||
class EventListAPIView(generics.ListAPIView):
|
||||
queryset = Event.objects.all()
|
||||
serializer_class = EventSerializer
|
Loading…
x
Reference in New Issue
Block a user