code:
diary=models.SablogArticles.objects.raw("SELECT articleid,DATE_FORMAT(from_unixtime(dateline),'%Y-%m')\
as newtime,count(*) as howmany FROM sablog_articles group by newtime")
The result gave me :
In template d:\python\project\tpl\base.html, error at line 68 Caught TypeError while rendering: not enough arguments for format string
The raw SQL is a string with formatting parameters, which means that % indicates a parameter to format. Your string has % in it. You need to double them to protect them from interpretation:
diary = models.SablogArticles.objects.raw("""
SELECT
articleid,
DATE_FORMAT(from_unixtime(dateline),'%%Y-%%m') as newtime,
count(*) as howmany
FROM sablog_articles group by newtime
""")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With