Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Join(APIView):
- def post(self, request, format=None):
- #current user
- user = request.user
- try:
- #item to join
- item = Items.objects.get(id = request.POST.get("id"))
- except Items.DoesNotExist:
- data = json.dumps({'status':"Item to join not found"})
- return HttpResponse(
- data, status=404, content_type="application/json"
- )
- item.attending_with.add(user)
- item.save()
- data = json.dumps({'status':"success"})
- return HttpResponse(data, status=200, content_type="application/json")
Add Comment
Please, Sign In to add comment