class UpdateIPv4UserMeta(object):
def process_view(self, request, view_func, view_args, view_kwargs):
user = request.user
today_30min = timezone.now() + timezone.timedelta(minutes=30)
if user.is_authenticated():
if user.last_login > today_30min:
User.objects.filter(id=request.user.id).\
update(latest_ip=request.META['REMOTE_ADDR'])
class Town(models.Model):
title = models.CharField(
verbose_name=u'название'.
blank=True, null=True,
max_lenght=255,
)
resorts = models.ForeignKey(
Resorts,
related_name='resort_town',
verbose_name=u'город',
blank=True
)
order = models.PositivIntegerField()
class Meta:
ordering = ['order']
verbose_name = u'страна'
verbose_name_plural = u'страны'