add manage.py command to recheck useragents

This commit is contained in:
j 2012-10-27 17:25:32 +02:00
commit 1872621d8c
4 changed files with 27 additions and 1 deletions

View file

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from optparse import make_option
from django.core.management.base import BaseCommand
import monkey_patch.models
from ... import models
class Command(BaseCommand):
"""
reparse all useragents. useful after updating python-ox
"""
help = 'reparse all useragents. useful after updating python-ox'
args = ''
def handle(self, **options):
ids = [s['session_key'] for s in models.SessionData.objects.all().values('session_key')]
for i in ids:
s = models.SessionData.objects.get(pk=i)
s.parse_useragent()
s.save()