장고 옴
class Product(models.Model):
    id = models.CharField(max_length=10, primary_key=True)
    title = models.CharField(max_length=225)
    slug = models.SlugField()
    description = models.TextField()
    # 9999.99
    unit_price = models.DecimalField(max_digits=6, decimal_places=2)
    inventory = models.ImageField()
    last_update = models.DateTimeField(auto_now=True)
    # then reference collection class here
    # PROTECT -> if accidentally delete Collection(Parent), PROTECT will protect our all Products (Child)
    collection = models.ForeignKey(Collection, on_delete=models.PROTECT)
    # we use plural because we have multiple promotions
    # many to many
    promotions = models.ManyToManyField(Promotion)
Reference
이 문제에 관하여(장고 옴), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/pooyaalamdari/django-orm-4o7c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)