18 lines
534 B
Python
18 lines
534 B
Python
from django.db import models
|
|
from django.contrib.postgres.fields import JSONField
|
|
|
|
|
|
class EntryManager(models.Manager):
|
|
def print(self, lines=100):
|
|
return self.model.objects.order_by('-timestamp')[:int(lines)].reverse()
|
|
|
|
|
|
class Entry(models.Model):
|
|
timestamp = models.DateTimeField(auto_now_add=True, db_index=True)
|
|
host = models.CharField(max_length=128, db_index=True)
|
|
data = JSONField()
|
|
objects = EntryManager()
|
|
|
|
def __str__(self):
|
|
return '%s %s %s' % (self.timestamp, self.host, self.data)
|