How to use the watchtower.models.Hit function in watchtower

To help you get started, we’ve selected a few watchtower examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github synw / django-watchtower / watchtower / db / orm / __init__.py View on Github external
def write(db, hits, verbosity=0):
    i = len(hits)
    hit_objs = []
    for hit in hits:
        if verbosity > 0 and i > 0:
            if verbosity > 2:
                print(json.dumps(hit, indent=2))
        hit_obj = Hit(
            path=hit["path"],
            method=hit["method"],
            ip=hit["ip"],
            user_agent=hit["user_agent"],
            authenticated=convertBool(hit["is_authenticated"]),
            staff=convertBool(hit["is_staff"]),
            superuser=convertBool(hit["is_superuser"]),
            username=hit["user"],
            referer=hit["referer"],
            view=hit["view"],
            module=hit["module"],
            status_code=int(hit["status_code"]),
            reason_phrase=hit["reason_phrase"],
            request_time=float(hit["request_time"]),
            doc_size=hit["doc_size"],
            num_queries=int(hit["num_queries"]),
github synw / django-watchtower / watchtower / admin.py View on Github external
# -*- coding: utf-8 -*-

from django.contrib import admin

from .models import Hit


@admin.register(Hit)
class HitAdmin(admin.ModelAdmin):
    list_display = (
        'created',
        'path',
        'method',
        'ip',
        'username',
        'device',
        'city',
    )
    list_filter = (
        'created',
        'edited',
        'authenticated',
        'staff',
        'superuser',