让我们说,我跟随Django模型设置如下:
@python_2_unicode_compatible
class Question(models.Model):
question_text = models.CharField(max_length=300)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question_text
@python_2_unicode_compatible
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
所以,当我试图在Django shell中执行这些操作时
q = Question.objects.get(pk=1)
q.choice_set().all()
而不是返回空或任何东西,它只是错误地输出以下消息:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/path/to/my/djangoproject/lib/python3.4/site-packages/django/db/models/fields/related_descriptors.py", line 505, in __call__
manager = getattr(self.model, kwargs.pop('manager'))
KeyError: 'manager'
我尝试过使用
q.choice_set()
但没有,同样的错误。任何帮助将不胜感激。
答案 0 :(得分:0)
应该是 q.choice_set.all()
public sub whatsoever()
Dim alfaarray() As Variant
Dim g As Integer
Dim obj As Object
ReDim alfaarray(4)
Set obj = New teszt
For g = 0 To 4
alfaarray(g) = "g" & CStr(g)
Next g
Call obj.init
CallByName obj, "GARG", VbLet, alfaarray
end sub