Flask-Currency
Currency handling extension for Flask.
Usage
###Initialization Initialize extension by providing Flask and Flask-SQLAlchemy instance.
from flask import Flask
from flask_currency import Currency
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
currency = Currency(app, db)
if __name__ == '__main__':
app.run()
Optionally, an extended currency model can be provided
(for translation support, etc.). If the model is not extended, it can be
accessed through the Currency.model attribute.
Money class
A money class is defined, which uses the Currency model for value calculation and formatting.
>>> from flask_currency import Money
>>> price = Money(100, 'USD')
>>> print(price)
'$100.00'
>>> in_eur = price.convert_to('EUR')
>>> print(in_eur)
'90.71 €'
Currencies
The currencies table must be maintained, currency data must be added manually.
eur = currency.model(
name='Euro',
code='EUR',
sign='€',
value=1,
format_str='{:,.2f} €'
)
db.session.add(eur)
db.session.commit()
Metadata
Release files for FlaskCurrency 1.0
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 | |
|---|---|---|---|---|
| FlaskCurrency-1.0.tar.gz | 2.9 kB | Without provenance | Details |
Release files / FlaskCurrency-1.0.tar.gz
| Download URL | FlaskCurrency-1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52c10e18b34d2a2c1cd3b9c2224b02f90ed1fa907899dfd1041b8b47f89f276e
|
|
BLAKE2b-256 checksum How to use checksums |
0a1e23d257521134cd04157547af9db849dfd569dd9530ae5d8cdabda8078c7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.0
|
Security for FlaskCurrency 1.0
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.