在我的Django应用程序中有以下数据模型:
class Company(models.Model):
company_name = models.CharField(max_length=255)
company_url = models.URLField(max_length=2048, blank=True, null=True)
...
class Meta:
db_table = 'company_table'
class PricingPlan(models.Model):
plan_name = models.CharField(max_length=255, blank=True, null=True)
...
company = models.ForeignKey(Company, related_name='pricing_plans', on_delete=models.CASCADE, blank=True, null=True)
class Meta:
db_table = 'pricing_plan_table'
class Feature(models.Model):
feature_name = models.TextField(blank=True, null=True)
plans = models.ManyToManyField(PricingPlan, related_name='features', blank=True)
class Meta:
db_table = 'feature_table'
class WebData(models.Model):
company = models.OneToOneField(Company, related_name='web_data', on_delete=models.CASCADE)
version = models.IntegerField(blank=True, null=True)
...
class Meta:
db_table = 'web_data_table'
字符串
现在,我想像这样查询DB:
queryset = queryset.select_related('web_data').prefetch_related('pricing_plans', 'pricing_plans__features')
型
但得到这个错误:
django.db.utils.ProgrammingError: relation "feature_table_plans" does not exist
LINE 1: ...e"."feature_name" FROM "feature_table" INNER JOIN "feature_t...
型
有什么解决办法吗?
1条答案
按热度按时间tktrz96b1#
尝试:
字符串