Skip to main content

Django like query for Flask-SQLAlchemy

Project description

Flask-DjangoQuery
=================

A module that implements a more Django like interface for Flask-SQLAlchemy query objects. It's still API compatible with the regular one but extends it with Djangoisms.

## Installation

Install Flask-DjangoQuery with pip:

$ [sudo] pip install Flask-DjangoQuery

Install Flask-DjangoQuery with easy_install:

$ [sudo] easy_install Flask-DjangoQuery

Or you can clone or download it then:

```bash
cd Flask-DjangoQuery
python setup.py install
```

## Usage

```python
from flask import Flask
from flask.ext.djangoquery import SQLAlchemy

app = Flask(__name__)

db = SQLAlchemy()
db.init_app(app)
```

Then you can use it just like [Flask-SQLAlchemy](https://github.com/mitsuhiko/flask-sqlalchemy) while have a more *Django like* `filter_by`, `exclude_by` and `order_by` interface.

### Define a model

```python
class Post(db.Model):
id = db.Column(db.Integer, primary_key=True)
pub_date = db.Column(db.Datetime)
title = db.Column(db.String(50))
```

## Example queries

```python
Post.query.filter_by(pub_date__year=2008)
Post.query.exclude_by(id=42)
Post.query.filter_by(title__contains='something')
Post.query.order_by('-post__pub_date')
```

For more please view the codes of [flask_djangoquery.py](flask_djangoquery.py)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

Flask-DjangoQuery-0.2.1.zip (7.4 kB view details)

Uploaded Source

Flask-DjangoQuery-0.2.1.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file Flask-DjangoQuery-0.2.1.zip.

File metadata

File hashes

Hashes for Flask-DjangoQuery-0.2.1.zip
Algorithm Hash digest
SHA256 47973e8866918da975f626034eb6a66c691c4702ab48f9e65220140a2e65108f
MD5 3d121b1498dc2fe5007924dcd1bbc396
BLAKE2b-256 e1cd913b493d951f0566d7b006cd2c288996c3d953d7ef1fc3c0f6ea9f99c340

See more details on using hashes here.

File details

Details for the file Flask-DjangoQuery-0.2.1.tar.gz.

File metadata

File hashes

Hashes for Flask-DjangoQuery-0.2.1.tar.gz
Algorithm Hash digest
SHA256 ef898ac877342a12dcaf50fdd0e5b6b6d2b9aec8ad1301fe74657919b9daff21
MD5 c6e8847f45111a4d1f45abbdf6db2242
BLAKE2b-256 0ce35e32d7b8722a1623ed6007ac29167c8c1ab28809c8698d0a3fac8091f2b6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page