On May 30, 12:11 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote: > As far as the first question, I would create my own group model. My > reasoning is pretty simple, I create models based on functionality or > purpose of the object. auth.groups is essentially used to assign > permissions to users, you are really looking to associate users with > other users. So while it could be done, I personally would not do it. I > would create a model called UserGroup or something similar.
Thanks, this helps a lot. > As for the second question, you cannot directly do this. You must use an > intermediate table, and I am not sure what you mean by 'extend the user > model' most people do this with a userprofile model with a one to one back > to user. So assuming you have UserProfile you could have: > > UserGame(models.Model): > user_profile = FK(UserProfile) > game = FK(Game) > high_score = integer() > > my $0.02 > -richard Yes, when I said extend the usermode, I meant making a userprofile model that has a one to one back to user. Also, I did think of thi solution of using an intermediate table, but I was thinking about it incorrectly. I was trapped into thinking along the lines of many2many relationships, so I thought that making an intermediate table would actually produce extra useless tables. Now I realize that using FK instead of M2M in the intermediate is the way to go. Thanks, this helps a lot. > > On 5/30/08, Apreche <[EMAIL PROTECTED]> wrote: > > > > > Hi, I'm a long-time developer, and moderately recent Django convert. > > Because Django is so awesome, and the freely available documentation > > is so great, I've had very few problems learning django, and getting > > things done. However, I often find myself battling with more design- > > level decisions than I did when working with other languages and > > frameworks. To get more specific, allow me to ask about two particular > > questions I have. > > > Let's say I want to make a site that allows users to form groups. They > > can create, join, and leave groups, and those groups are not much more > > than a way for users to associate themselves with other users. It's a > > simple model that has a many2many relationship with users. Should I > > tie this functionality into the django.contrib.auth groups > > application, or should I put it on its own? The auth groups are mostly > > used for setting user permissions more easily, so it seems like this > > other group functionality should be separate. Tying it into the auth > > app might also pose some security concerns. However, if the auth app > > is being included, making a separate group app seems redundant. And it > > seems as if security would not be a concern if it were coded > > properly. > > > Here's another one. Let's say I have a model for games and a model for > > users. I want to associate users with games, so I extend the user > > model and create a many2many relationship between users and games. > > However, I also want to keep track of high scores. I want to apply a > > value to the relationship itself. If I were making the database by > > hand, I would create a cross reference table with columns for userid, > > gameid, and highscore. Making a model in django, achieving this sort > > of database structure does not seem possible. What is the "proper" way > > to model this sort of design in django? > > > Thanks for your help. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---