You probably solved that already but... You go to .../api/bookings/ while your urls.py makes a redirection for .../api/booking (there's an analogy to .../api/workspace from the right image).
W dniu niedziela, 23 września 2018 11:17:51 UTC+2 użytkownik Tim Vogt napisał:
-- W dniu niedziela, 23 września 2018 11:17:51 UTC+2 użytkownik Tim Vogt napisał:
I have made an Rest api on django 2.0 with works fine with one api view api/workspacebut 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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d638456d-eace-4ca2-9700-020ed958d4de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment