Last active
August 29, 2015 14:14
-
-
Save jeyraof/7b224b98ec2406ac8d8b to your computer and use it in GitHub Desktop.
This file contains 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
class User(models.Model): | |
~~~~ | |
class Post(models.Model): | |
author = models.ForeignKey(User) | |
column_a = modelsIntegerField(default=0) | |
@property | |
def comments(self): | |
return self.comment_list.order_by('created_at') | |
class Comment(models.Model): | |
author = models.ForeignKey(User) | |
post = models.ForeignKey(Post, related_name='comment_list') | |
tmp = [] | |
for j in tmp_list: | |
tmp += Post.objects.filter(column_a=int(j)).select_related('author', | |
'comment_list', | |
'comment_list__author') | |
# pass tmp to template, | |
# and Use tmp.comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment