文章詳情頁
django進(jìn)行數(shù)據(jù)庫的查詢
瀏覽:134日期:2022-06-09 16:54:56
問題描述
class User(models.Model):
username = models.Charfield()
class Topic(models.Model):
# 發(fā)帖人
user = models.ForeignKey(User)
class Reply(models.Model):
topic = models.ForeignKey(Topic)
# 回復(fù)的人
user = models.ForeignKey(User)
現(xiàn)在需要查詢出一個(gè)用戶的發(fā)的帖子的所有的回復(fù)
user = User.objects.get(pk=5)
replies = Reply.objects.filter(topic.user.id==user.id)
一直報(bào)錯(cuò):
SyntaxError: keyword can't be an expression
請問得怎么處理,才可以獲取所有的回復(fù)。
問題解答
回答1:django不熟,幫不了你哈,打破0回復(fù),~~
相關(guān)文章:
1. mysql 的datadir設(shè)置的文件夾不存在,啟動(dòng)了mysql服務(wù)后創(chuàng)建的數(shù)據(jù)庫存在哪里?2. 數(shù)據(jù)庫 - MySQL 單表500W+數(shù)據(jù),查詢超時(shí),如何優(yōu)化呢?3. mysql多表查詢4. 求大神幫我看看是哪里寫錯(cuò)了 感謝細(xì)心解答5. 這是什么情況???6. python 多進(jìn)程 或者 多線程下如何高效的同步數(shù)據(jù)?7. php自學(xué)從哪里開始?8. phpstudy v8打開數(shù)據(jù)庫就出錯(cuò),而phpstudy 2018不會(huì)9. python - from ..xxxx import xxxx到底是什么意思呢?10. phpstady在win10上運(yùn)行
排行榜

熱門標(biāo)簽