On Wed, Feb 18, 2009 at 4:14 PM, May <adles...@gmail.com> wrote:

>
> Hello Karen,
>
> What I need then is to rewrite the model statement.  I imported the
> tables from MySQL, so the table structures were already set.  Should I
> add a manytomany field in the contact table?  I'm concerned about
> django creating a new separate table from the intermed table I already
> have. Resolving this problem will probably solve my admin template
> issue, which is that on the publication screen, I can reveal a contact
> for the publication, but I can't reveal the institutions the contact
> is associated with.
>

? Switching from what you have to a ManyToMany field in Contact doesn't
fundamentally change anything -- you still retain the possibility of
multiple Institutions per Contact.

You first need to answer the question as to whether that data model is
correct.  If it makes no sense that Contacts are associated with multiple
Institutions in whatever real data situation you are modeling, if Contacts
are logically associated with only a single Institution, then it would
probably be more appropriate for your Contact model to have a ForeignKey to
Institution.  Then the question "What Institution is associated with this
Contact?" will have exactly one answer (or None, iff null/blank is allowed
for that ForeignKey). This seemed to be what you were assuming in your
template code, but I don't know if it matches the real data you are
modeling, as it does not match your defined data models.

If, however, in your real data model it makes sense for Contacts to be
associated with multiple Institutions, then the right answer is to fix your
code to recognize that "Institution for this Contact" makes no sense, and
wherever you are looking for that answer the right thing, probably, is to
substitute "list of Institutions for this Contact".

Only someone who understands the actual data being modeled here can say what
the right answer is.  Who set up these tables initially in MySQL?  They seem
to have allowed for a possibility that you don't seem to think is valid, but
I have no idea which one correctly matches the actual data you are modeling.

Karen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to