This is just a simple demo project for work with Stackoverflow API. You can make request for a list of posts by user ID or get all of your posts via OAuth.
Python=3.6.2
Django=1.11.6
I use there SQLite database since I don't see any reasons for use another one like Postgres in this project. However you can use it if you want.
For OAuth I use Python Social Auth library.
You can change env variables there.
For production environment you should copy this file, change values and rename the file to variables-prod.env
.
For development I use test credentials and unfortunately this user has no posts. So you may need to change this data. As I said before you need to do that in the files of environment variables.
Assotiations according this documentation:
SOCIAL_AUTH_STACKOVERFLOW_KEY
- client IDSOCIAL_AUTH_STACKOVERFLOW_SECRET
- client secretSOCIAL_AUTH_STACKOVERFLOW_API_KEY
- API key
With Docker power and make it can be very easy.
For dev containers:
make build-dev
make
make manage-dev CMD=migrate
Or for production containers:
make build-prod
make up-pord
That's all! If you can't use make see commands there
Below you can see some useful commands for manipulate docker containers via make:
make build-dev
- Create networks if they don't exist and build dev imagesmake up-dev
- Run dev containers (shortcutmake
)make stop-dev
- Stop dev containersmake down-dev
- Stop containers and remove containers, networks, volumes, and imagesmake restart-dev
- Restart the application containermake logs-dev
- Show last 200 logs from the application containermake tests-dev
- Run testsmake manage-dev CMD='command'
- Run any command realted with manage. E.g.:make manage-dev CMD=migrate
will do./manage.py migrate
in the application containermake cmd-dev CMD='command'
- Run any command. E.g.:make cmd-dev CMD=ls
will dols
in the application containermake reload-prod
- Reload gunicorn in the application container (Only for production)
You can use almost of all commands for manage production containers, just use prod
insted dev
. E.g. make build-prod
.
In this case you should use standard Django commands.
You should have virtualenv
I assume that you are in a directory of the project:
virtualenv env
- create new virtual environmentsource env/bin/activate
- activate itpip install -r requirements
- install all requirements to the environment./manage.py migrate
- migrate all rpoject migrations./manage.py runserver
- run dev server