Skip to main content

Flask-like interface for Django

Project description


Do you like the niceties of Flask, but have to use Django for some reason? Are you a lunatic?

If you answered yes twice, this library is for you!

Supports Python 2.6 to 3.7, and Django 1.8+


Install package.

pip install flango

Create Flango app, add it to your urls.

from flango import Flango

app = Flango(__name__)

def index(pk):
    from django.contrib.auth.models import User
    return User.objects.get(pk=pk).first_name

urlpatterns = app.urlpatterns


  • Access current request anywhere

    from django import forms
    from flango import request
    class MyForm(forms.Form):
       def save(self):
           instance = super(MyForm, self).save(commit=False)
           instance.user = request.user
           return instance
  • Declare your routes alongside your views

    from flango import render_template
    from myapp import app
    def about():
       return render_template('about.html')
  • Typed variable parts

    from flango import render_template
    from myapp import app
    def map(lat, long):
       assert isinstance(lat, float)
       assert isinstance(long, float)
       return render_template('map.html', lat=lat, long=long)
  • Return response content, status code, and headers directly from views

    from myapp import app
    def ok():
       return 'ok'
    def idk():
       return 'idk', 404
    def wat():
       return 'wat', 400, {'Content-Type': 'text/wat'}
  • Save precious PEP-8 space when building URLs

    from django.db import models
    from flango import url_for
    class MyModel(models.Model):
       def get_invitation_link(self, friend_name):
           return url_for('my-model-invite',, friend_name=friend_name)

Using flango.request with regular Django views

Flango wraps your view functions to provide the request object globally. When your form or other code which accesses flango.request is called from a regular Django view, it will fail.

To fix this, add Flango's global_request_middleware to your settings.MIDDLEWARE:

    # ...

For best results, place it at the top of the list. This allows you to use flango.request in other middlewares.

Project details

Download files

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

Source Distribution

flango-0.0.2.tar.gz (5.5 kB view hashes)

Uploaded source

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