我正在从文档中学习django。
以下是models.py
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)这在shell中执行:
q = Question.objects.get(pk=1)
>>> q.choice_set.all()
<QuerySet []>这里使用why q.choice_set而不是q.Choice_set
choice_set是内置函数还是由于models.py中的选择而被使用,如果是,为什么它的第一个字母在小的情况下被取下来?
https://stackoverflow.com/questions/41217539
复制相似问题