Suppose, A is the request.user. And 'msg' has all the mesasges sent by the
user A and all the messages that A has received. Now how will I separate
the messages for each user from 'msg', to make it like an Inbox for A. I
think I have made it clear now. If not, please ask again.
Thank you.


On Sun, Aug 18, 2013 at 2:17 PM, Avraham Serour <tovm...@gmail.com> wrote:

> so what's the question?
>
>
> On Sat, Aug 17, 2013 at 7:52 AM, Karl Arunachal <
> kakararunachalserv...@gmail.com> wrote:
>
>> Hello,
>> I have a model for messaging between the users.
>>
>> models.py:
>>
>> class Message(models.Model):
>>     description = models.TextField()
>>     date_added = models.DateTimeField(default=datetime.now)
>>     sender = models.ForeignKey(User, related_name='sent_set')
>>     recipient = models.ForeignKey(User, related_name='recieved_set')
>>
>>     def __unicode__(self):
>>         return "%s sent message: %s to %s" % (self.sender, self.description, 
>> self.recipient)
>>
>>     def save(self, **kwargs):
>>         if self.sender == self.recipient:
>>             raise ValueError("Cannot message yourself")
>>         super(Message, self).save(**kwargs)
>>
>>
>>
>> Till now I get all the messages (sent/recieved) of a particular user,
>>
>> from django.db.models import Q
>>
>>
>>
>> A = request.usermsg = Message.objects.filter(Q(sender=A)|Q(recipient=A))
>>
>>
>>
>> Suppose, msg has all the messages sent and recieved for user 'A'. Now
>> how would i filter from this 'msg',  all the message sent to and recieved
>> from a particular user 'B'.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to