brydon, You won't get two almost identical tables if you use the above linked approach. Reason being is that the above approach effectively constructs the additional table needed for a many-to-many relationship explicitly. The model Writer is effectively the users_user_link table. Not that no fields in any of the models have a ManytoMany field - the Writer model and the two ForeignKey fields are doing the job of the ManyToMany field.
Sam On Mar 9, 11:59 am, brydon <[EMAIL PROTECTED]> wrote: > That's helpful and I'll likely take that approach but I believe that > means I have two almost identical tables? > > I'll likely get these table names wrong don't pay too much attention > to them....Say I created a UserLink class that had user, link, and > date_created. I think I'd end up with a users_user_link and a > users_userlink table which are identical except one contains the added > date_created column right? > > Ideally I'd just have the one table or am I missing something? > > thanks, > brydon > > On Mar 8, 7:22 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > > > On Sat, 2008-03-08 at 16:19 -0800, brydon wrote: > > > I know this answer should exist somewhere in documentation or on the > > > net, hopefully someone can point me there. I'm looking for model help > > > and I think I can frame it best with an example. Say you're building a > > > delicious like model. You have users, user have links. Those links > > > have common elements such as url, title, screengrab. They also have a > > > context unique to a user, like the date the user added the link. > > > > This leads to at least 3 main db tables. Users, Links, and UserLinks. > > > A user adds the link tohttp://www.djangoproject.com/whichresults in > > > a link and userlink entry. When the next user adds a link to > > >http://www.djangoproject.com/, that only results in an update to > > > userlink. > > > > I believe django supports this well by having a ManyToManyField in > > > User for Links. It will then create the intermediary join table and > > > manage it, which is perfect. The trick is that I want to add more data > > > to that intermediary table, for example the date when this particular > > > user added this link, etc. From a model perspective, ideally that > > > extra information is simply part of the link a user has. > > > The ManyToManyField is for when you just care about the ends, not the > > intermediate linkage. If you also want to work with the intermediate > > table, use this approach: > > > http://www.djangoproject.com/documentation/models/m2m_intermediary/ > > > There's some extra syntax coming in the future to make this type of > > setup behave more like ManyToManyfield in terms of the syntax you use > > when moving from one end to the other (not touching the intermediate > > table), however that won't change the table setup or anything like that > > from the above example. > > > Regards, > > Malcolm > > > -- > > Remember that you are unique. Just like everyone > > else.http://www.pointy-stick.com/blog/- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---