Suppose I have a model structure like this:
class Cheese(Model.models):
type = models.CharField(max_length='50')
class Sauce(Models.models):
type = models.CharField(max_length='50')
class Pizza(Models.models):
cheese = models.ForeignKey(Cheese)
sauce = models.ForeignKey(Sauce)
class PizzaOrder(Models.model):
pizza = models.ForeignKey(Pizza)
time = models.DateTimeField(auto_now_add=True)
Given this, now I want to create a new entry for PizzaOrder--but I do not want any duplicates of Cheese, Sauce, or Pizza--just PizzaOrder to represent that a pizza was just ordered.
This results in an error, which is discussed here.
How can I avoid this problem? I do not want a duplicate of object Pizza every-time I get a new PizzaOrder.