def get_queryset(username, follow): profile = get_object_by_username(Profile, username) profile_follow = get_object_by_username(Profile, follow) return profile_follow, profile
def get_queryset(self, *args, **kwargs): username = self.kwargs.get('username') profile = get_object_by_username(Profile, username) block = get_object_by_user(Blockuser, profile) return profile, block
def get_queryset(self, *args, **kwargs): users = Profile.objects.all() post = Post.objects.all().order_by('-id') username = self.request.user.username profile = get_object_by_username(Profile, username) return users, post, profile
def get_queryset(self, request, *args, **kwargs): username = self.kwargs.get('username') profile = get_object_by_username(Profile, username = username) following = get_object_by_user(Following, profile) follower = get_object_by_user(Follower, profile) block = get_object_by_user(Blockuser, profile) return profile, following, follower, block
def get_follower_total(profile): profile = get_object_by_username(Profile, username=profile) follower = get_object_by_user(Follower, user=profile) try: count = follower.followers.count() except AttributeError: count = 0 return count
def block_unlock_user(request, block_user): user = request.user.profile block_user = get_object_by_username(Profile, block_user) print('user', user) block_user_obj = get_object_by_user(Blockuser, user=user) print('block user obj', block_user_obj) if block_user_obj: if block_user in block_user_obj.blocked.all(): print('remove') block_user_obj.remove(block_user_obj, block_user) else: print('update') block_user_obj.update(block_user_obj, block_user) else: Blockuser().create(Blockuser, user, block_user) return HttpResponse("Success")