some, related, questions을 읽었지만 내 사례가 무엇인지 모르는 것이 명확하지 않습니다. 저는 데이터베이스 n00b를 배우려고 노력 중이므로 인내심을 느낍니다. 회사의django : 다중 테이블 상속을 호출하는 ManyToMany 속성을 쿼리
- 3 종류 : 제조 업체, 리셀러, ServiceNRepair이 (공유 약 10 특성) 제품의
- 5 유형 : StuffedAnimals, 자전거, 바비 인형 (일부 속성을 공유하는)
# company.models.py
class GenericCompany(models.Model):
name, description, address, etc
class Manufacturer(GenericCompany): #can manufacture different things
stuff_specific_to_manufacturers
product = models.ManyToMany(GenericProduct)
class Reseller(GenericCompany): #can sell different things
stuff_specific_to_manufacturers
product = models.ManyToMany(GenericProduct)
etc for ServiceNRepair
과 :
그래서 유지하는 일이 내가 멀티 테이블 상속을 시도 DRY
# product.models.py
class GenericProduct(models.Model):
name, price, color, etc
class StuffedAnimal(GenericProduct):
fluffyness, ears_or_not, etc
class Bicycle(GenericProduct):
wheel_diameter, weight, etc
etc for Barbies
는 지금은
- 쇼처럼
- 이 업체는 어떤 제품을 생산 않습니다 (이 용이하다) 빨간색 모든 제품을 쿼리를 수행해야하는거야?
- X는
판매하는 리셀러 모든 자전거를 찾기하지만 M2M으로 그렇게 할 수 있습니까? Manufacturer.objects.filter(product_icontains ='something')
그런 일은 작동하지 않습니다. 그래서, 나는 완전히 잘못된 길에있다? ContentTypes를 사용하는 일반적인 솔루션입니까? 나는이 문제를 해결하기 위해 무엇을 공부해야할지에 관해 어느 정도 방향성을 지니고 싶다. 어떤 팁 감사. 고맙습니다.
언급 한 검색어에 대해서도 필요하지 않지만 –