def create(self, request):
        new_attraction_item = Attraction()
        new_attraction_item.name = request.data["name"]
        #I'm not sure how to obtain a foreign key.
        new_attraction_item.area_id = request.data["area_id"]
        new_attraction_item.save()
        serializer = AttractionSerializer(new_attraction_item,
                                          context={'request': request})

        return Response(serializer.data)
Example #2
0
    def create(self, request):
     
        newattraction = Attraction()
        newattraction.name = request.data["name"]
        newattraction.area_id = request.data["area_id"]
        newattraction.save()

        serializer = AttractionSerializer(newattraction, context={'request': request})

        return Response(serializer.data)
Example #3
0
    def create(self, request):
        """Handle POST operations

        Returns:
            Response -- JSON serialized ParkArea instance
        """
        newattraction = Attraction()
        newattraction.name = request.data["name"]
        newattraction.area_id = request.data["area"]
        newattraction.save()

        serializer = AttractionSerializer(newattraction, context={'request': request})

        return Response(serializer.data)