flango!
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+
Quickstart
Install package.
pip install flango
Create Flango app, add it to your urls.
# urls.py
from flango import Flango
app = Flango(__name__)
@app.route('/<int:pk>')
def index(pk):
from django.contrib.auth.models import User
return User.objects.get(pk=pk).first_name
urlpatterns = app.urlpatterns
Benefits
-
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 instance.save() return instance
-
Declare your routes alongside your views
from flango import render_template from myapp import app @app.route('/about') def about(): return render_template('about.html')
-
Typed variable parts
from flango import render_template from myapp import app @app.route('/map/<float:lat>/<float:long>') 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 @app.route('/ok') def ok(): return 'ok' @app.route('/idk') def idk(): return 'idk', 404 @app.route('/wat') 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', id=self.id, 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:
# settings.py
MIDDLEWARE = (
'flango.global_request_middleware',
# ...
)
For best results, place it at the top of the list. This allows you to use flango.request in other middlewares.
Metadata
Release files for flango 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flango-0.0.2.tar.gz | 5.5 kB | Without provenance | Details for flango-0.0.2.tar.gz |
Release files / flango-0.0.2.tar.gz
| Download URL | flango-0.0.2.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59b75bf2f611a3036d9cb0b83ae7ef2d8e8657a599d54b7e6ec88987c8b469c3
|
|
BLAKE2b-256 checksum How to use checksums |
1592285abcfd0d7926e54f5a126fc9b5554fd34e7d438519fd61b1276cfa4f02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for flango 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.