Hi everyone,

class Post(models.Model):
    author = models.ForeignKey('auth.User',on_delete=models.CASCADE,)
    title = models.CharField(max_length=200)
    text = RichTextField()
    created_date = models.DateTimeField(default=timezone.now)
    published_date = models.DateTimeField(blank=True, null=True)

    def __str__(self):
        return self.title

this is my sample model

and this is my view

def index(request):
    fetch_post_data =
Post.objects.filter(published_date__lte=timezone.now()).order_by('-created_date')[:5]
    fetch_pgraph_data = Post.objects.raw("select count(title) as
uno,published_date from blog_post group by DATE(published_date)")
    #fetch_pgraph_data = Post.objects.raw("select * from blog_post")
    template_var = {'postodj':fetch_post_data,'userdataobj':fetch_pgraph_data}
    return render(request,'home.html',context=template_var)


when I am trying to fetch the data using *fetch_pgraph_data*, it's showing
Raw query must include the primary key


-- 
Soumyajit Banerjee
<https://www.facebook.com/recklessLYF>
<https://www.linkedin.com/in/soumyajit-banerjee-11992b25/>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG8c6EFsFt_1UwgSch_1mY92x%2BboSrwow7H5umj4-WeYs0f2hg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to