Hello all, I have the following models (among others):

class Project(models.Model):
    client = models.ForeignKey(User)
    notes = models.TextField()
    service = models.CharField(max_length=25)
    # more fields

class Circuit(models.Model):
    pointA = models.CharField(max_length=20)
    pointB = models.CharField(max_length=20)
    # more fields

class Union(models.Model):
    project = models.ForeignKey(Project)
    circuit = models.ForeignKey(Circuit)
    tdm = models.ForeignKey(Voip)
    type = models.CharField(max_length=5)
    # more fields

class Attachment(models.Model):
    project = models.ForeignKey(Project)
    docfile = models.FileField(...)
    # more fields


One project can have several circuits (this is a service, as well as for 
example Voip), and one circuit can belong to several projects, so it's a 
M-N relationship.
In my view, I need to show the ModelForm of Project and Form of Attachment 
(easy for now) and depending on the value of the field 'service', load the 
next form into an iframe (it's an idea). For example, if they choose 
Circuit, load ModelForm of Circuit, if is voip is chosen load ModelForm of 
Voip, etc.

My doubt and issue here is how to accomplish this, because I would need to 
save both items first (Project and Circuit) and then create a new entry in 
Union model with the corresponding IDs and I don't know how can I retrieve 
the IDs in this case.

It would be like:
1. Save Circuit (store the id somewhere)
2. Save Project (store the id somewhere)
3. New entry in Union (circuit_id, project_id)

Maybe I'm overthinking this, but I do not see a clear solution

Thank you very much in advance for the help

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to