我的模型上的名字有问题。在“皮尔多拉”班上,有一个外国钥匙在场上:布洛克。我已经指出了你的名字,但它不工作。你知道吗
我有这些模型:
class Bloque(models.Model):
titulo = models.CharField(max_length=200)
letra = models.CharField(max_length=1)
descripcion = models.CharField(max_length=200)
tema = models.ForeignKey(Tema, on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
slug = models.SlugField(max_length=1)
updated_at = models.DateTimeField(auto_now=True)
class Pildora(models.Model):
titulo = models.CharField(max_length=200)
descripcion = RichTextField(max_length=2000, config_name='default')
slug = models.SlugField(max_length=20)
url = models.URLField(max_length=200)
tipo = models.ForeignKey(TipoPildora, on_delete=models.CASCADE)
identificador = models.IntegerField()
pildora_anterior = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
bloque = models.ForeignKey(Bloque, on_delete=models.CASCADE, related_name='%(app_label)s_%(class)s_related')
activo = models.BooleanField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
但当我使用:
bloque = Bloque.objects.filter(tema__asignatura__slug=kwargs["asignatura"], tema__slug=kwargs["tema"], slug=kwargs["bloque"])
print(bloque.formacion_pildora_related)
Django说:
AttributeError: 'QuerySet' object has no attribute 'formacion_pildora_related'
我读了《django医生》,但我找不到为什么会这样:S 我能做什么?你知道吗
注:在有问题的情况下,%(应用程序标签)s%(类)s\u相关指的是'形式'pildora\u bloque'。我给它起了固定的名字,比如“pildoras”,甚至没有报道,所以在默认情况下,它被用作“set\u pillora”,但这些都不起作用。你知道吗
非常感谢大家,真的。我被困住了,有点沮丧。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐