Orange County Lettings Website
- GitHub account with read access to this repository
- Git CLI
- SQLite3 CLI
- Python interpreter, version 3.6 or higher
In the rest of the local development documentation, it is assumed the command python
in
your OS shell runs the above Python interpreter (unless a virtual environment is activated).
cd /path/to/put/project/in
git clone https://github.com/OpenClassrooms-Student-Center/Python-OC-Lettings.git
cd /path/to/Python-OC-Lettings
python -m venv venv
apt-get install python3-venv
(If previous step errors with package not found on Ubuntu)- Activate the environment
source venv/bin/activate
- Confirm the command
python
now runs the Python interpreter in the virtual environment,which python
- Confirm the version of the Python interpreter is 3.6 or higher
python --version
- Confirm the command
pip
runs the pip executable in the virtual environment,which pip
- To deactivate the environment,
deactivate
cd /path/to/Python-OC-Lettings
source venv/bin/activate
pip install --requirement requirements.txt
python manage.py runserver
- Go to
http://localhost:8000
in a browser. - Confirm the site is running and can be navigated (you should see several profiles and lettings).
cd /path/to/Python-OC-Lettings
source venv/bin/activate
flake8
cd /path/to/Python-OC-Lettings
source venv/bin/activate
pytest
cd /path/to/Python-OC-Lettings
- Open a shell session
sqlite3
- Connect to the database
.open oc-lettings-site.sqlite3
- Display tables in the database
.tables
- Display columns in the profiles table,
pragma table_info(Python-OC-Lettings_profile);
- Run a query on the profiles table,
select user_id, favorite_city from Python-OC-Lettings_profile where favorite_city like 'B%';
.quit
to exit
- Go to
http://localhost:8000/admin
- Login with user
admin
, passwordAbc1234!
Using PowerShell, as above except:
- To activate the virtual environment,
.\venv\Scripts\Activate.ps1
- Replace
which <my-command>
with(Get-Command <my-command>).Path
Deploy directly to Heroku on one click
The fastest way to deploy and test the application on Heroku is by clicking the following link:
Log into your heroku account, enter a name for the application and click deploy.
All the required environment variables will be taken from this repo automatically.
After the process is completed you will be able to visit and test the web application.
Deploy the app from your system to Heroku
-
If you haven't already, log in to your Heroku account typing
heroku login
-
Create a new app on either using the web UI (to pick an available name)
or typingheroku create
(wich will create the app with a random name) -
Add the SECRET_KEY environment variable using web UI:
app > Settings > Config Vars > Reveal Config Vars > Add
KEY:SECRET_KEY
VALUE:SOME_SECRET_VALUE
Or using cli:heroku config:set SECRET_KEY=SOME_SECRET_VALUE -a HEROKU_APP_NAME
-
Open the cli and navigate to the Python-OC-Lettings folder
-
Initialize a git repository in a new or existing directory:
- initialize git:
git init
- add heroku remote:
heroku git:remote -a HEROKU_APP_NAME
- initialize git:
-
Commit your code to the repository and deploy it to Heroku using Git:
- add files:
git add .
- commit added files:
git commit -am "commit message"
- deploy on heroku:
git push heroku master
- add files: