Skip to main content

Provide search statistic for Django framework.

Project description

Installation

  1. pip install django-search-statistic

  2. Add search_statistic to settings.INSTALLED_APPS

  3. Add ‘search_statistic.middleware.CollectStatisticMiddleware’ to settings.MIDDLEWARE_CLASSES

  4. python manage.py migrate search_statistic

Usage

If you want specify content_type and object_pk (default only path is stored) you must add to your views: from search_statistic.utils.visits import visit_object

def some_view(request):

obj = SomeModel.objects.get(pk=pk)

visit_object(request, obj)

Settings

All settings stored in settings.SEARCH_STATISTIC. Default value is:

{

‘REDIS_CACHE_SIZE’: 1,

‘REDIS_PREFIX’: ‘django-search-statistic’,

‘REDIS_SETTINGS’: {

‘db’: 1

},

‘REMOVE_ON_STATUS’: [400, 403, 404, 405],

‘default_query_confirm’: False,

}

Options REDIS_* are using only where redis are installed. If REDIS_CACHE_SIZE <= 0 - search queries will storing in redis infinitely. If REDIS_CACHE_SIZE == 1 - redis isn’t using If REDIS_CACHE_SIZE >= 2 - search queries and visits are storing in cache, but after REDIS_CACHE_SIZE objects in cache they will be saved in DB

If response status code in REMOVE_ON_STATUS all visits with path == current request.path are deleteing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-search-statistic-0.0.1.tar.gz (15.7 kB view details)

Uploaded Source

File details

Details for the file django-search-statistic-0.0.1.tar.gz.

File metadata

File hashes

Hashes for django-search-statistic-0.0.1.tar.gz
Algorithm Hash digest
SHA256 300fd618cb4a6fb82dc732e9b9a0b2e0e1bea17e658d3463dea9a232342a9692
MD5 574ed33b81aa691cdfe59a5c0a878e13
BLAKE2b-256 e8d62b2e6573c32e26f5d3073609071afec0d0a3ba851601a4de271d1d9a5fed

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page