Per user vote behind proxy
Opened this issue · 1 comments
Hi, thanks for great application.
REMOTE_ADDR is always 127.0.0.1 and I don't need it to be unique, just per user voting.
Does application support that ?
Thank you.
Sometimes I'm getting errors like this when voting for the first time :
Traceback:
File "/opt/envs/tworoads/lib/python3.5/site-packages/updown/fields.py" in add
108. rating, created = Vote.objects.get(**kwargs), FalseFile "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/query.py" in get
385. self.model._meta.object_nameDuring handling of the above exception (Vote matching query does not exist.), another exception occurred:
File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)The above exception (duplicate key value violates unique constraint "updown_vote_content_type_id_af6fe292_uniq"
DETAIL: Key (content_type_id, object_id, key, user_id, ip_address)=(20, 117, dfa5be7e620204da91e72a33294e9798, 3, 127.0.0.1) already exists.
) was the direct cause of the following exception:File "/opt/envs/tworoads/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
39. response = get_response(request)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)File "/opt/envs/tworoads/lib/python3.5/site-packages/updown/views.py" in call
105. request, content_type.id, object_id, field_name, score)File "/opt/envs/tworoads/lib/python3.5/site-packages/updown/views.py" in call
42. field.add(score, request.user, request.META['REMOTE_ADDR'])File "/opt/envs/tworoads/lib/python3.5/site-packages/updown/fields.py" in add
111. rating, created = Vote.objects.create(**kwargs), TrueFile "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/query.py" in create
399. obj.save(force_insert=True, using=self.db)File "/opt/envs/tworoads/lib/python3.5/site-packages/updown/models.py" in save
43. super(Vote, self).save(*args, **kwargs)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/base.py" in save
796. force_update=force_update, update_fields=update_fields)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/base.py" in save_base
824. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/base.py" in _save_table
908. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/base.py" in _do_insert
947. using=using, raw=raw)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/query.py" in _insert
1045. return query.get_compiler(using=using).execute_sql(return_id)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
1054. cursor.execute(sql, params)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/utils.py" in exit
94. six.reraise(dj_exc_type, dj_exc_value, traceback)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/utils/six.py" in reraise
685. raise value.with_traceback(tb)File "/opt/envs/tworoads/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)Exception Type: IntegrityError at ....
Exception Value: duplicate key value violates unique constraint "updown_vote_content_type_id_af6fe292_uniq"
DETAIL: Key (content_type_id, object_id, key, user_id, ip_address)=(20, 117, dfa5be7e620204da91e72a33294e9798, 3, 127.0.0.1) already exists.
Hi!
There is no way to turn off ip checking currently. 😢
A fix would be to configure your reverse proxy to set the correct ip as `REMOTE_ADDR.