but it does not show the data with the view of the booking form . Any tips how to solve it?
Tim
#api/serializers.py
from rest_framework import generics
from rest_framework import serializers
from workspace.models import Workspace_booking
class Workspace_bookingSerializer(serializers.ModelSerializer):
class Meta:
model = Workspace_booking
fields = ( 'id','name','address','description','totalSpots','spotsTaken','location')
class Bookings_bookingSerializer(serializers.ModelSerializer):
class Meta:
model = Workspace_booking
fields = ('id','date','workplaceId','people','note')
#api urls.py
from django.urls import path
from .views import Workspace_bookingApiView , Workspace_bookingApiView_detail
from .views import Bookings_bookingApiView , Bookings_bookingApiView_detail
urlpatterns = [
path('workspace', Workspace_bookingApiView.as_view()),
path('<int:pk>/', Workspace_bookingApiView_detail.as_view()),
path('booking', Bookings_bookingApiView.as_view()),
path('<int:pk>/', Bookings_bookingApiView_detail.as_view())
]
#api views.py
from django.shortcuts import render
from rest_framework import generics
from workspace.models import Workspace_booking
from bookings.models import Bookings_booking
from .serializers import Workspace_bookingSerializer
from .serializers import Bookings_bookingSerializer
class Workspace_bookingApiView(generics.ListAPIView):
queryset = Workspace_booking.objects.all()
serializer_class = Workspace_bookingSerializer
class Workspace_bookingApiView_detail(generics.RetrieveUpdateDestroyAPIView):
queryset = Workspace_booking.objects.all()
serializer_class = Workspace_bookingSerializer
class Bookings_bookingApiView(generics.ListAPIView):
queryset = Bookings_booking.objects.all()
serializer_class = Bookings_bookingSerializer
class Bookings_bookingApiView_detail(generics.RetrieveUpdateDestroyAPIView):
queryset = Bookings_booking.objects.all()
serializer_class = Bookings_bookingSerializer
No comments:
Post a Comment