Hi,
I have two models, as follow,
class Feed(models.Model):
user=ForeignKey(...)
class Comment(models.Model):
feed=ForeignKey(Feed, ...)
comment_text=TextField(...)
I want get last two comments for each feed, the statement is:
Comment.objects.all().extr(select={'row_num': 'row_number() over (partition by feed_id order by id desc', where=['row_num<3']}
After run, Django told me these error:
....
....
But remove where parameter, it works.
Comment.objects.all().extr(select={'row_num': 'row_number() over (partition by feed_id order by id desc'}
-- I have two models, as follow,
class Feed(models.Model):
user=ForeignKey(...)
class Comment(models.Model):
feed=ForeignKey(Feed, ...)
comment_text=TextField(...)
I want get last two comments for each feed, the statement is:
Comment.objects.all().extr(select={'row_num': 'row_number() over (partition by feed_id order by id desc', where=['row_num<3']}
After run, Django told me these error:
....
Django Version: | 1.8.2 |
---|---|
Exception Type: | ProgrammingError |
Exception Value: | column "row_num" does not exist LINE 1: ...nt"."create_date" FROM "footprint_comment" WHERE (row_num < ... |
But remove where parameter, it works.
Comment.objects.all().extr(select={'row_num': 'row_number() over (partition by feed_id order by id desc'}
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8d955586-fbc9-42a7-b34d-ddc3b8fc50b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment