This is a backend implementing a chart storage with Python and PostgreSQL. You can run this storage on your server to process users' saved data such as chart layouts, drawing templates, and indicator templates. For more information, refer to the Saving and loading charts section of the Advanced Charts documentation.
Python 3x, pip, Django, PostgreSQL
- Clone the repository to your host machine.
- Install Python 3.x and pip. Use a virtual environment if your host has an older Python version that cannot be upgraded.
- Install PostgreSQL or any other Django-friendly database engine. You can also install pgAdmin or any other administrative tool for your database.
- Go to your chart storage folder and install the required dependencies:
pip install -r requirements.txt
. For Unix users: you should have the python-dev package to installpsycopg2
. - Create an empty database in PostgreSQL using either the command line or pgAdmin.
- Configure your database connection in
charting_library_charts/settings.py
(seeDATABASES
at line 16). - Run
python manage.py migrate
to create the database schema without any data. - Generate a secret key by running
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
. - Set your secret key to your environment variables
export SECRET_KEY='...'
. - Start a test instance of your database by running
python manage.py runserver
. Note that for production environments, you should avoid usingrunserver
and instead use a suitable WSGI (Web Server Gateway Interface) server like Gunicorn. - Set
charts_storage_url
in the Widget Constructor to the URL of your chart storage. Additionally, ensure to setclient_id
anduser_id
.