Django Many-to-Many Question
- by DZ
My questions seems like a common problem that when I have seen any questions on it is never really asked right or not answered. So Im going to try to get the question right, and maybe someone knows how to resolve the issue, or correct my understanding.
The problem:
When you have a many-to-many relation ship (related_name not through) and you are trying to use the admin interface you are required to input one of the rleationships even though it does not have to exsist for you to create the first entry. Meaning you have to assign a group to an event to create the group. Wow that sounds complicated. So I can see why the question is not getting answered.
Lets try the non code explanation example...
First and important versions:
Django 1.1.1
Phython 2.6
So I have a model where I created a many-to-many realtionship and Im using the related_name
Im creating an app that is an event organizer, for simplicty lets say events although they could be anytype). For this first post Im going to stay away from the code and just try to explain.
A few keys:
(explaining comment)
** - many-to-many
So in the model we have
1) The Main Event (this is main model)
2) Groups (link to events and their can be many events for a group)
a) Events**
I have simplified this example a little becuase I recognize that what does it matter. Just create the event first... But there are specific varations where that will not work.
What the many-to-many related_name does it created another table with the indecies of the two other tables. Nothing says that this extra table HAS to be populated. Becuase if I look in the database and work within myPHPadmin I can create a group with out registering an event, since the connection between the two is a seperate table the DB does not care. How do I make the admin interface this realize it?
Ok I know thats a lot so I hope I have explained it clearly. Thank you anyone for your comments/thoughts/advice