mirror of
https://github.com/Sosokker/ku-polls.git
synced 2025-12-18 13:04:05 +01:00
2.9 KiB
2.9 KiB
Installation
There are two ways to install and run this project.
- Use
setup.pyorsetup.ps1(for windows) to install the project. - Manually install the project with the Instruction in section 2.
1. Use setup.py or setup.ps1(for windows) to install the project.
- Install Python 3.11 or later
- Clone this repository and Run
setup.pyto install and run the project
Don't forget to answer the question from setup.py to setup the project
This method will autogenerate Environment Variable for you.
git clone https://github.com/Sosokker/ku-polls
cd ku-polls
python setup.py
If you want to customize the environment variables, name of environment folder then run this command
python setup.py -custom
or run setup.ps1 (For Windows User)
2. Manually install the project with this instruction.
- Install Python 3.11 or later
- Run these commands to clone this repository and enter the directory.
git clone https://github.com/Sosokker/ku-polls
cd ku-polls
- (Optional: You can use venv instead)Install virtualenv via pip
python -m pip install --user virtualenv
- Create virtual environment with
venvorvirtualenv.
python -m virtualenv venv
or
python -m venv venv
- Use
virtual environment
- Windows
.\venv\Scripts\activate
- Linux or MacOS
source venv/bin/activate
- Install require module.
pip install -r requirements.txt
- Create file call
.envinku-pollsdirectory and add this line You can look atsample.envfor more information and others environment variables to set.
SECRET_KEY=your_secret_key
DEBUG = False
ALLOWED_HOSTS = *.ku.th, localhost, 127.0.0.1, ::1
TIME_ZONE = Asia/Bangkok
EMAIL_HOST_PASSWORD = yourpassword
You can generate your own your_secret_key by this command
python manage.py shell -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
or
Don't forget to change your_secret_key to your secret key (without quote)
- Migrate database and load data into it then runserver.
python manage.py migrate
python manage.py loaddata data/users.json
python manage.py loaddata data/polls.json
python manage.py loaddata data/vote.json
python manage.py runserver
NOTE
By Default DEBUG=False and Django will not load Static files for you so if you want to apply CSS run this.
python manage.py runserver --insecure
or set DEBUG=True
or do the collectstatic
Then connect to http://127.0.0.1:8000/ or localhost:8000/