django-defender/defender/models.py

43 lines
1.1 KiB
Python
Raw Normal View History

2015-01-06 01:20:24 +00:00
from __future__ import unicode_literals
2014-09-24 00:31:17 +00:00
from django.db import models
2015-01-06 01:20:24 +00:00
from django.utils.encoding import python_2_unicode_compatible
2014-09-24 00:31:17 +00:00
2015-01-06 01:20:24 +00:00
@python_2_unicode_compatible
2014-09-24 00:31:17 +00:00
class AccessAttempt(models.Model):
user_agent = models.CharField(
max_length=255,
)
ip_address = models.GenericIPAddressField(
verbose_name='IP Address',
null=True,
)
username = models.CharField(
max_length=255,
null=True,
)
http_accept = models.CharField(
verbose_name='HTTP Accept',
max_length=1025,
)
path_info = models.CharField(
verbose_name='Path',
max_length=255,
)
attempt_time = models.DateTimeField(
auto_now_add=True,
)
login_valid = models.BooleanField(
default=False,
)
class Meta:
ordering = ['-attempt_time']
2015-01-06 01:20:24 +00:00
def __str__(self):
""" unicode value for this model """
2015-01-06 01:20:24 +00:00
return "{0} @ {1} | {2}".format(self.username,
self.attempt_time,
self.login_valid)