def owner_required(function):
def wrap(request, *args, **kwargs):
print(request)
ip_address = get_client_ip(request)
ip_exist = Node.objects.get(ip_address=ip_address)
if ip_exist:
return function(request, *args, **kwargs)
else:
raise PermissionDenied
return wrap
def get_client_ip(request):
""" Extract ip address from a Django request object
"""
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get('REMOTE_ADDR')
return ip
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
AttributeError: 'function' object has no attribute 'META'
@owner_required
def all(request, **kwargs):
pass
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0e34ae73-5697-4a93-9402-c0ca1f4abd70%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0e34ae73-5697-4a93-9402-c0ca1f4abd70%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/69879830-d7ad-4914-a8d4-7ac1ba1d8241%40googlegroups.com.