First you need to install the necessary dependencies for this project
-
Install Python.
-
Clone project and Install python virtual environment.
git clone https://github.com/GGWPXXXX/ku-polls
python -m pip install virtualenv
- Create a new
.env
file in the project's root directory. You can use a text editor of your choice to create and edit the file, you can see the sameple insample.env
.
SECRET_KEY = secret-key-value-without-quotes
DEBUG = False
ALLOWED_HOSTS = *.ku.th, localhost, 127.0.0.1, ::1
TIME_ZONE = Asia/Bangkok
- Create new environment.
cd ku-polls
python -m venv venv
- Run this command to anable virtual environment.
venv\Scripts\activate
But if the program prompted you with an error "Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?" then use.
Set-ExecutionPolicy Unrestricted -Scope Process
venv\Scripts\activate
- Use the following command to install necessary dependencies.
pip install -r requirements.txt
- Run the program.
python manage.py migrate
python manage.py loaddata data/users.json
python manage.py loaddata data/polls.json
python manage.py loaddata data/choice.json
python .\manage.py runserver
- If you want to exit the program simply hit ctrl+c to deactivate django server and use
deactivate
in your terminal to exit virtual environment.
If you want to see the unit tests of this project simply run,
python manage.py test
Note : Make sure that when you run test you still in virtual environment.