-
Notifications
You must be signed in to change notification settings - Fork 1
Backend
Python, Django, Django Rest Framework, Pandas, Numpy
The following image clearly shows the structure of the API endpoints and how they are used by various views on the frontend.

The various data, numbers are computed at the backend using Python and Pandas at the backend.
-
Clone the Repository
$ git clone https://github.com/EnsemblGSOC/ecircdb-backend.git ecircdb-backend $ cd ecircdb-backend -
Make virtual environment setup
$ pip install virtualenv $ virtualenv -p python3 <env_name>
The aim is to create an independent python3 environment so that the project's dependencies and their version doesn't mix with the local ones ensuring a smooth flow of the app.
-
Activate your environment
$ source <env_name>/bin/activate
-
Install
libmysqlclientFor example on Debian/Ubuntu you must install the package:
sudo apt-get install libmysqlclient-dev
For recent versions of debian/ubuntu (as of 2018) it is:
sudo apt install default-libmysqlclient-dev
The step is important to install the pip dependency
mysqlclient==1.4.2.post1. It requires certain binary files on the host, to connect MySQL database with the Django framework. -
Install requirements
$ pip install -r requirement.txt
Install various pip packages required in the app from the given file. It's always important to update the file using
pip freeze > requirement.txtwith the active environment whenever there is a change in the packages or their version. -
Create a MySQL user and database normally, remember the name of the database and credentials for the user. Do not create any table structure in your newly created database, all those things should be handled via Django ORM.
-
Configure the .env file for the project, you can clone the available
.env.stencilfile to checkout the format for .env file$ cp .env.stencil .env
The file contains the simple configurables, which are used at various places by Django. For ex the credentials to connect with the MySQL server.
-
Fill out the database name, user, password in the .env file, you can specify the host and port for the database optionally.
-
Migrate Files
$ python manage.py makemigrations $ python manage.py migrate
This is the step where the Django ORM does its work. It creates the database schema according to the model structure we defined.
-
Create a superuser to control the admin panel
$ python manage.py createsuperuser
-
Start the server
$ python manage.py runserver
-
Visit
localhost:8000/controland login using the account created in above step. This is the admin panel from where data can be added, deleted or modified. -
Check other urls from the list at
localhost:8000/api/
