How to filter from two conditions?

I have a model for user groups:

class ProfileGroup(models.Model):
    user = models.ManyToManyField(user)
    name = models.CharField(max_length=100)

And a model for article:

class Article(models.Model):
    title = models.CharField(max_length=200)
    text = models.TextField()
    group = models.ForeignKey(ProfileGroup)
    owner = models.ForeignKey(user)

The user can edit own articles and articles from groups which is assigned.

How to retrieve all user articles and from his groups? Do I need to use Q? Maybe suffice filter?

articles = Article.object.filter(....


To get a user's articles:


To get articles that belong to one of the user's groups.


You can then get use Q to get articles which belong to that user or one of the user's groups.


Need Your Help

PHP Cache Headers with CDN

php apache .htaccess cache-control

I am trying the php header() function to set caching headers to my page. I have a CDN that caches the http requests. What I am trying to achieve here is that the CDN should cache my page for 2 days...

How Memcached negotiate the protocol?

memcached binary protocols ascii

I know that Memcached can negotiate protocol with the client, but I know nothing (neither can found anything on Internet) about the negotiation mechanism the server use. Any idea?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.