1
私はDjango(v1.9.4)にちょっとひっかかった。私は、fooと バーを二つのモデルを作成しました:Django foo_set doesnt work
class Foo(models.Model):
name = models.CharField(max_length=100)
class Bar(models.Model):
foo_id = models.ForeignKey(Foo, on_delete=models.CASCADE)
title = models.CharField(max_length=300)
は、それ(sqlite3の)といくつかの瞬間を移行後には
fooの代わりにfoo_idなければならないことを実現:
foo = models.ForeignKey(Foo, on_delete=models.CASCADE)
今回はfooで再度移行しましたが、この修正後も使用できませんでした
f = Foo.objects.filter(pk=1)
f.bar_set.all()
これに対処する方法はありますか?
編集。 エラーメッセージ: 例外の種類:はAttributeError 例外値:「foo」でオブジェクトがfilter
リターン(リストである)QuerySet
、オブジェクトではありませんので、働いていない無属性「bar_set」
エラーメッセージはありますか? – ilse2005
編集した私の質問、tnx – Prpaa