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
精彩评论