A Django/Python app for displaying stock exchange stats related to T&T
- Python 3
-
Install the virtualenvwrapper package using the command
pip install virtualenvwrapper
on Linux orpip install virtualenvwrapper-win
on Windows. -
Clone the repo
-
On a terminal, go to the directory where you cloned the repo and execute the command
mkvirtualenv -p python3 trinistatsenv -r requirements.txt
to create a virtual Python3 environment for this app and install the packages from the requirements.txt file simultaneously. -
a.Enter your virtual env using the command
workon trinistatsenv
b.Use the command
python -V
to verify that you are running Python3 inside this virtualenv.c.Exit from the virtualenv using the command
deactivate
. -
The following instructions are for using Visual Studio Code, if you're using a different IDE please refer to its documentation
-
Open VS Code and select 'File>Open Folder' and navigate to folder where you cloned the repo.
-
On the left hand side, click the Extensions button (fifth one). Ensure that Python, Django, django-intellisense and MagicPython are installed.
-
Now click the Run button (fourth one on the left) and click the settings gear icon above the Variables keyword. The launch.json file should open. Paste this code to overwrite that entire file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/trinistats/manage.py",
"args": ["runserver", "--noreload"],
"django": true
}
]
}
-
Close that file. Now you have two dropdowns in the Run command at the top left. One to run your currently open Python script, and one to run our manage.py script for our Django project.
-
Press 'CTRL + ,' to open the settings window. In the search bar at the top, enter venv and enter '~/.virtualenvs' in the Python:Venv Path input bar. Press enter and restart the IDE.
-
Press the CTRL+SHIFT+P keys and select Python: Select Interpreter. Look for the 'trinistatsenv' environment there. If it does not show up, try other solutions here
-
Now go back to the Run button on the left hand side, select the dropdown, ensure that Python:Django is selected and click the green run button.
-
Check the output of the terminal to see if Django isn't happy about anything.
-
Hopefully everything runs and you can navigate to 127.0.0.1:8000