This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.cache import cache | |
| from django.conf import settings | |
| from django.contrib.auth.models import User | |
| ONLINE_THRESHOLD = getattr(settings, 'ONLINE_THRESHOLD', 60 * 15) | |
| ONLINE_MAX = getattr(settings, 'ONLINE_MAX', 50) | |
| def get_online_now(self): | |
| return User.objects.filter(id__in=self.online_now_ids or []) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| <head> | |
| <title></title> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I was working on a problem similar to this yesterday, and I found the best solution for me personally was to use the object_list generic view for all date-based pages, but pass a filtered queryset, as follows: | |
| import datetime, time | |
| def post_archive_month(request, year, month, page=0, template_name='post_archive_month.html', **kwargs): | |
| # Convert date to numeric format | |
| date = datetime.date(*time.strptime('%s-%s' % (year, month), '%Y-%b')[:3]) | |
| return list_detail.object_list( | |
| request, | |
| queryset = Post.objects.filter(publish__year=date.year, publish__date.month).order_by('-publish',), |
NewerOlder