Building complex queries programmatically.
This type of question is not really appropriate for the peewee issue tracker.

This is not an issue but a question.
I have to build complex queries programmatically.

For ex:

For this model:

``` python
class Article(Model):
    title = CharField(null=False, unique=False, index=True)
    permalink = CharField(default=None, unique=True, null=True)
    tags = ArrayField(CharField, null=True, default=[], index=True)
    keywords = ArrayField(CharField, null=True, default=[], index=False)
    summary = TextField(null=True)
    content = TextField(default='')
    series_id = IntegerField(default=0, index=True)
```

Through an API request on web, I will receive the filter like this,

``` json
{
  "fields_wanted": ["title", "permalink", "summary"],
  "series_id": [1, 2]
}
```

Through the above post request data, I basically want to generate this query:

``` python
articles = Article.select(Article.title, Article.permalink, Article.summary).where(
   Article.series_id.in_(1, 2)).execute()
```

I was thinking to generate like this (after validating the json):

``` python
fields = [getattr(Article, field) for field in post_data["fields_wanted"]]
articles = Article.select(fields).where(
    getattr(Article, "series_id").in_(data["series_id"])).execute()
```

Is this a good way or can it be implemented in some other way?
How would I go about doing the above?
