0
不幸的是,我仍在使用django 1.4,verbose_name不適用於外鍵。 有沒有辦法改變外鍵的標籤。現在,它不工作:Django:在管理中更改字段標籤不起作用
class ProductVariant(models.Model):
product = models.ForeignKey(TestProduct, verbose_name='test product', on_delete=models.PROTECT)
ProductVariant
class ProductVariantForm(forms.ModelForm):
product = forms.ModelChoiceField(queryset=TestProduct.objects.order_by("product__article_code"))
test_software = forms.ModelChoiceField(queryset=TestSoftware.objects.order_by("name"))
class Meta:
model = ProductVariant
class ProductVariantAdmin(admin.ModelAdmin):
fields=["product", "test_software", "test_variables", "name", "description"]
list_display = ("name", "product_name", "test_software_name", "test_variables", "description")
search_fields = ["name"]
form = ProductVariantForm
我希望你能幫助我。
提前致謝!
嘗試:'product = models.ForeignKey(TestProduct,verbose_name = u'test product',on_delete = models.PROTECT)'如果它有效,我會發布我的答案。 – Silwest
@Silwestpl它沒有工作:'( – Ruben