Quickstart¶
Prerequisites¶
Accounts:
GitHub account with read access to this repository
Sentry.io account, with a project configured for the oc_lettings app
Softwares:
Python interpreter, version 3.6 or higher
Environement variables:
OC_LETTING_SK= the secret key of the projectOC_LETTING_SENTRY_KEY= your sentry DSN KeyDJANGO_DEBUG= 0 or 1, to configure django on production mode
Throughout the rest of the documentation for local development, it is assumed that the python command
in your OS shell executes the above Python interpreter (unless a virtual environment is activated).
Clone the Repository¶
cd /path/to/put/project/in
git clone https://github.com/VisualDev-FR/openclassrooms-p13
Create the Virtual Environment¶
Create a new virtual env
cd /path/to/cloned/repo
python -m venv venv
Activate the environment
./venv/bin/activate
upgrade pip
pip install --upgrade pip
To deactivate the environment
deactivate
Run the site with Django¶
cd /path/to/cloned/repo
venv/bin/activate`
pip install -r requirements.txt`
python manage.py collectstatic
python manage.py runserver 0.0.0.0:8000
Go to http://localhost:8000 in a browser.
Confirm that the site is working, and you can navigate (you should see several profiles and locations).
Run the site with Docker¶
As an alternative to run the site with django, you can build and run a docker container.
cd /path/to/cloned/repo
Build the docker image
docker build
--no-cache
--tag <your_image_name>
--build-arg OC_LETTING_SENTRY_KEY="$OC_LETTING_SENTRY_KEY"
--build-arg OC_LETTING_SK="$OC_LETTING_SK"
.
Run the builded image
docker run -p 8000:8000 <your_image_name>
Go to http://localhost:8000 in a browser.
Confirm that the site is working, and you can navigate (you should see several profiles and locations).
Linting¶
cd /path/to/cloned/repo
source venv/bin/activate
python -m flake8
Unit Tests¶
cd /path/to/cloned/repo
source venv/bin/activate
python -m pytest
Test Coverage¶
pytest --cov-config=setup.cfg --cov=. --cov-report html