diff --git a/dashboard/models.py b/dashboard/models.py index 36ed681..e1da43b 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -50,6 +50,7 @@ class Group(models.Model): village = models.CharField('村', max_length=256, null=True, blank=True) classify = models.CharField( '分类', max_length=256, null=True, blank=True, choices=GROUP_CLASSIFY_CHOICES) + rank = models.IntegerField('rank', default=0) user = models.ForeignKey( User, on_delete=models.CASCADE, blank=True, null=True) @@ -670,6 +671,9 @@ class News(models.Model): def __str__(self): return self.title + class Meta: + ordering = ["-date"] + # 手机验证码验证表 class CheckCode(models.Model): diff --git a/polls/views/__pycache__/news.cpython-38.pyc b/polls/views/__pycache__/news.cpython-38.pyc index b278239..e08a792 100644 Binary files a/polls/views/__pycache__/news.cpython-38.pyc and b/polls/views/__pycache__/news.cpython-38.pyc differ diff --git a/polls/views/news.py b/polls/views/news.py index 15b4020..305912c 100644 --- a/polls/views/news.py +++ b/polls/views/news.py @@ -10,7 +10,7 @@ from polls.decorators import polls_login_required @polls_login_required def news_list(request): category = request.GET.get('category', '1') - news_list = News.objects.filter(type=category) + news_list = News.objects.filter(type=category).order_by('-date') results = [] for o in news_list: result = dict()