示例#1
0
def like_pet(req, pet_id):
    pet = Pet.objects.get(pk=pet_id)
    like = Like()
    like.pet = pet
    like.save()

    return redirect('list pets')
示例#2
0
def like(request, pk):
    try:
        some_pet = Pet.objects.get(pk=pk)
        some_like = Like(pet=some_pet)
        some_like.save()
    except ObjectDoesNotExist:
        return redirect('pet_detail', pk)
    return redirect('pet_detail', pk)
示例#3
0
def like_pet(request, pk):
    # already_liked = Likes.objects.first(user_id=user.id, pk=pk)
    # if already_liked :
    #     return
    pet = Pet.objects.get(pk=pk)
    like = Like(test=str(pk))
    like.pet = pet
    like.save()
    return redirect('pet details or comment', pk)
示例#4
0
文件: views.py 项目: tsec0/project
def like_pet(request, pk):
    liked = Like.objects.filter(user_id=request.user.userprofile.id, pet_id=pk)
    if liked:
        liked.delete()
    else:
        pet = Pet.objects.get(pk=pk)
        like = Like(test=str(pk), user=request.user.userprofile)
        like.pet = pet
        like.save()
    return redirect('pet details or comment', pk)
示例#5
0
def pet_like(request, pk):
    like = Like.objects.filter(user_id=request.user.userprofile.id, pet_id=pk).first()
    if like:
        like.delete()
    else:
        pet = Pet.objects.get(pk=pk)
        like = Like(test=str(pk), user=request.user.userprofile)
        like.pet = pet
        like.save()
    return pet_details(request, pk)
示例#6
0
def pets_likes(request, pk):
    like = Like.objects.filter(user_id=request.user.userprofile.id,
                               pet_id=pk).first()
    if like:
        like.delete()
    else:
        pet_obj = Pet.objects.get(pk=pk)
        #zakachai kum user, a ne user profile
        like = Like(user=request.user.userprofile)
        like.pet = pet_obj
        like.save()
    return redirect('pets details', pk)
示例#7
0
def like_pet(req, pk):
    #checks if liked and dislikes
    like = Like.objects.filter(user_id=req.user.userprofile.id, pet_id=pk).first()
    if like:
        like.delete()
    else:
        pet = Pet.objects.get(pk=pk)
        # new_like = pet.like_set.create()
        like = Like(pet=pet, user=req.user.userprofile)
        like.save()
        pet.like_set.add(like)
        pet.save()
        return redirect('pet_details', pk)
示例#8
0
def like_pet(request, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like(test=str(pk))
    like.pet = pet
    like.save()
    return redirect(f'../details/{pet.id}')
示例#9
0
def pet_like(request, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like(test=str(pk))
    like.pet = pet
    like.save()
    return pet_details(request, pk)
示例#10
0
def like_pet(req, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like(like_id=pk)
    like.pet = pet
    like.save()
    return redirect('list pet')
示例#11
0
def like_pet(request, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like(test=str(pk))
    like.pet = pet
    like.save()
    return redirect('pet details or comment', pk)
示例#12
0
def pets_like(request, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like(test=str(pk))
    like.pet = pet
    like.save()
    return redirect('pet-detail', pk)
示例#13
0
def pet_like(request, pk):
    pet = Pet.objects.get(pk=pk)
    like = Like()
    like.pet = pet
    like.save()
    return redirect("pet detail or comment", pk)