This is a REST API project created using python, Django and Django Rest Framework.
To run the project, run python manage.py runserver
- To access the local env, go to http://localhost:8000
- To manage items, to go the admin panel at http://localhost:8000/admin
- Create admin user:
python manage.py createsuperuser
- Create migrations:
python manage.py makemigrations finance_api
- Migrate db:
python manage.py migrate
This projects uses PipEnv to organize the python dependencies.
To install PipEnv, you need to have python and pip already installed (the recommended version of python is python 3.9).
pip install pipenv
After installing, make sure you can execute pipenv
from your terminal.
If not, you will need to add it to your path variable, such as:
# find out where your python dependencies are installed
export PYTHON_PATH=`python3 -m site --user-base`
#after having the path, update your PATH variable with your python path
export PATH=$PATH:$PYTHON_PATH/bin
# install dependencies
pipenv install --dev
# then you can run anything in the project, everything should be already installed
pipenv run python3 sync.py
- Set the Python interpreter to use the local pipenv environment.
- First, run
pipenv --venv
from the terminal to get the path to your interpreter - In VS Code,
cmd+shift+p
and selectPython: select interpreter
- Select the
+ Enter interpreter path...
option - Enter the path that got from running
pipenv --venv
in the first step
- First, run
- Add a launch file at
.vscode/launch.json
with the following contents:{ "version": "0.2.0", "configurations": [ { "name": "Python: Django", "type": "python", "request": "launch", "program": "${workspaceFolder}/app/manage.py", "args": ["runserver"], "django": true, "justMyCode": true } ] }
- Go to the debug tab in VS Code, select the
Python: Django
option and click the start (▶️ ) button to start the server. You should be able to set breakpoints in code and hit them while debugging.