jose-lpa / django-tracking-analyzer

User actions tracking and analytics for Django sites :bar_chart:
GNU General Public License v3.0
96 stars 32 forks source link

Support for Non-int object_pk values? #5

Open bashu opened 6 years ago

bashu commented 6 years ago
...
(0.007) INSERT INTO "tracking_analyzer_tracker" ("content_type_id", "object_id", "timestamp", "ip_address", "ip_country", "ip_region", "ip_city", "referrer", "device_type", "device", "browser", "browser_version", "system", "system_version", "user_id") VALUES (39, 54043139220559890978892722548666079386, '2018-03-08T08:41:25.830854+00:00'::timestamptz, NULL, '', '', '', 'http://localhost:8080/v1/', 'pc', 'Other', 'Firefox', '58.0', 'Mac OS X', '10.11', 1) RETURNING "tracking_analyzer_tracker"."id"; args=(39, 54043139220559890978892722548666079386, datetime.datetime(2018, 3, 8, 8, 41, 25, 830854, tzinfo=<UTC>), None, '', '', '', 'http://localhost:8080/v1/', 'pc', 'Other', 'Firefox', '58.0', 'Mac OS X', '10.11', 1)
Traceback (most recent call last):
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.DataError: integer out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
    self.result = application(self.environ, self.start_response)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
    response = self.get_response(request)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
    response = self._middleware_chain(request)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 44, in inner
    response = response_for_exception(request, exc)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 94, in response_for_exception
    response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = get_response(request)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
    response = self._get_response(request)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework/viewsets.py", line 90, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework/views.py", line 489, in dispatch
    response = self.handle_exception(exc)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework_tracking/mixins.py", line 37, in handle_exception
    response = super(BaseLoggingMixin, self).handle_exception(exc)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework/views.py", line 449, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework/views.py", line 486, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/rest_framework/mixins.py", line 56, in retrieve
    instance = self.get_object()
  File "/home/vagrant/morpheus/djangoapp/activity/api.py", line 94, in get_object
    Tracker.objects.create_from_request(self.request._request, obj)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/tracking_analyzer/manager.py", line 78, in create_from_request
    user=user
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/query.py", line 399, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/base.py", line 796, in save
    force_update=force_update, update_fields=update_fields)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/base.py", line 824, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/base.py", line 908, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/base.py", line 947, in _do_insert
    using=using, raw=raw)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/query.py", line 1045, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1054, in execute_sql
    cursor.execute(sql, params)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/debug_toolbar/panels/sql/tracking.py", line 164, in execute
    return self._record(self.cursor.execute, sql, params)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/debug_toolbar/panels/sql/tracking.py", line 106, in _record
    return method(sql, params)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/vagrant/.virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: integer out of range

In my application I'm using UUIDField instead of PositiveIntegerField for primary keys

semics-tech commented 4 years ago

Same issue here, did you find a resolution?

jose-lpa commented 4 years ago

Currently only positive integer values are accepted by design.

If you have an improvement for this you can submit a pull request.