0

django 관리 사이트에서 외래 키 모델 필드를 다른 모델의 필드 (목록 표시 아님)로 표시 할 수 있습니까? 나는 가격의 외래를 가진 제품과 가격 모델을 가지고있다. 나는 product와 Variation 모델 모두에서 price, sale_price 및 sale을 편집 가능한 필드로 표시하려고합니다.django 관리 사이트 외래 키 필드

class Price(models.Model): 
    price = models.DecimalField(decimal_places=2, max_digits=8) 
    sale_price = models.DecimalField(decimal_places=2, max_digits=8) 
    sale = models.BooleanField(default=False) 

class Product(models.Model): 
    title = models.CharField(max_length=120) 
    description = models.TextField(blank=True, null=True) 
    price = models.ForeignKey('Price') 

class Variation(models.Model): 
    product = models.ForeignKey(Product) 
    price = models.ForeignKey('Price') 
    title = models.CharField(max_length=120) 

답변

1
+0

이가, 즉 반대되는 외래 키 관계 때문에 작동하지 않습니다는 – Uma

+0

@Judy 인라인가 ** ** 역 관계를 –

+0

@Marcio 정확한 내가하지만 찾고 있었다되지 않은 가격 모델이지만 제품 모델에없는 그 주위를 돌아 다녔다. 제품 및 변형 모델에서 읽기 전용 필드를 생성했습니다. – Uma