I wan to implement likes counter in my blog and am using the users IP address to unique identify the user. All is working fine on local machine but am getting an error "IpModel matching query does not exist" when I run it on pythonanywhere.com server.
Here is the snippet of my get client IP function;
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_REAL_IP')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
return ip
and the other potion of the code is;
like_status = False
ip = get_client_ip(self.request)
if self.object.likes.filter(id=IpModel.objects.get(ip=ip).id).exists():
like_status = True
else:
like_status=False
context['like_status'] = like_status
[edit by admin: formatting]