On Sun, 2007-03-04 at 12:02 +0000, Henrik Lied wrote: > Hi there, > > I'm creating a social network app. with lots of features. Among those > features are the possibility of users creating groups. A group of > course has an owner, and the owner is supposed to be able to assign > moderators to that group. I have a mockup of a model, but I don't > think it's good enough. > > Current model: > class Group(models.Model): > creator = models.ForeignKey(User, raw_id_admin=True, > verbose_name='gruppeadmin', related_name='Creator of the group') > name = models.CharField(maxlength=200, verbose_name='gruppenavn') > slug = models.SlugField(prepopulate_from=['name',], unique=True) > > moderator_1 = models.ForeignKey(User, raw_id_admin=True, > null=True, blank=True, related_name='Moderator number one') > moderator_2 = models.ForeignKey(User, raw_id_admin=True, > null=True, blank=True, related_name='Moderator number two') > moderator_3 = models.ForeignKey(User, raw_id_admin=True, > null=True, blank=True, related_name='Moderator number three') > moderator_4 = models.ForeignKey(User, raw_id_admin=True, > null=True, blank=True, related_name='Moderator number four') > moderator_5 = models.ForeignKey(User, raw_id_admin=True, > null=True, blank=True, related_name='Moderator number five') > > description = models.TextField('beskrivelse') > category = models.ForeignKey(GroupCategory, > verbose_name='gruppekategori') > > creation_date = models.DateTimeField(auto_now_add=True) > > -------- > > Have any of you created a similar feature, or is able to give me some > feedback on how it's done properly? :-)
I think you might have overlooked a good use for the ManyToMany field here. The link between moderators and a Group is many-to-many (each group has many moderators and each moderator can potentially belong to many groups). I would replace moderator_1 through _5 with a single moderator attribute that is ManyToMany(User, ...). If you absolutely must restrict the number of moderators to five, maximum, then you will need to write a custom validator to check that feature. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---