开发者

django many to many with 3 models

I am creating a ticket app, the app has 3 models: Ticket, Parent, Variation. The variation model has a one to many relationship with Parent, and ticket has a m2m with Variation. What i am trying to do is be able to select a parent and/or variation from the add ticket page, but using the filter_vertical or something similar, that way i can choose one or the other from the same drop down . heres the models.py

class Ticket(models.Model):
    STATUS = (
        (0, "Open"),
        (1, "Closed"),
    )

    status = models.SmallIntegerField(default=0,choices=STATUS)
    title = models.CharField(max_length=100)
    product = models.ManyToManyField(Variation)
    parent = models.ManyToManyField(Parent)
    submitted_date = models.DateField(auto_now_add=True)
    modified_date = models.DateField(auto_now=True)
    description =开发者_如何学C models.TextField(blank=True)

class Variation(models.Model):

    qb = models.IntegerField(unique=True, verbose_name="QuickBooks #")
    parent = models.ForeignKey("Parent")

class Parent(models.Model):
    item = models.CharField(max_length=100, verbose_name="product #")
    date = models.DateField()

any help is appreciated, thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜