Revision: 19328
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 21, 2009 14:12 by vas3k
Initial Code
### models.py class UsersOnline(models.Model): username = models.CharField(max_length=100) time = models.DateTimeField() url = models.URLField() def __unicode__(self): return self.username def recountUsersOnline(): users = UsersOnline.objects.all() date_now = datetime.now() # Deleting expired users for user in users: dt = date_now - user.time if (dt.seconds > 300): # User expired user.delete() def addUserOnline(username, url): try: user = UsersOnline.objects.get(username=username) user.time = datetime.now() except: user = UsersOnline(username=username, time=datetime.now(), url=url) user.save()
Initial URL
Initial Description
Initial Title
Users Online on Django
Initial Tags
python, user, django
Initial Language
Django