skink wrote: > Hi, > > I'd like to model the following situation: > > 1. there are a writers (instance of MyUser class) who can write several > Note's > 2. each Note can have several readers (instances of MyUser class) > > eg. we have user1, user2, user3 and user4 > > user1 writes note1 that needs to be read by user2 and user3 > user1 writes note2 that needs to be read by user3 and user4 > > i did the model: > > from django.core import meta > > class MyUser(meta.Model): > name = meta.CharField(maxlength=30) > > def __repr__(self): > return self.name > > class Note(meta.Model): > noteText = meta.CharField(maxlength=100) > writer = meta.ForeignKey(MyUser) > publications = meta.ManyToManyField(MyUser) > > def __repr__(self): > return self.headline > > but i don't know how to: > 1 get list of Notes written by given MyUser (for user1 it'd be [note1, > note2] with v91 user1.get_note_list()
> 2. for a given Note get list of its readers (for note1 it'd be [user2, > user3], for note2 [user3, user4]) I assuming publications is list of readers with v91 note1.get_publications_list() I don't think there is anything wrong with this model, but I'm not so smart. You probably need to use the related_name parameter as described here http://www.djangoproject.com/documentation/model_api/#many-to-many-relationships Studying the model examples is wise: http://www.djangoproject.com/documentation/models/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---