Designed to utilitze daily tasks for LINE users.
- Python v3.8.1
- Pip v19.3.1
- Ngrok v2.3.35
- Psql v10.12 - Optional if you will use SQLITE3 instead
Ensure you have cloned/pulled the repository to your local. Open terminal from the root repository and run all these commands at once for setup.
- Create virtual local python environment
python -m venv env
- Activate local environment, you can find a away to do that from this section
- Install all dependencies.
pip install -r requirements.txt
- Create .env in the root repository and add necessary environment variables as follow:
Variable Optional Value Default LINE_CHANNEL_SECRET No The host of database server LINE_CHANNEL_TOKEN No The port that used by the host DEBUG No Either 1 or 0 1 ALLOWED_HOSTS Yes List of allowed hosts and separated by comma * DBMS Yes Either SQLITE3 or POSTGRESQL SQLITE3 DATABASE_NAME Yes Targeted database, ensure you have created on your DBMS DATABASE_USER Yes User's name to access the database DATABASE_PASSWORD Yes User's password to access the database DATABASE_HOST Yes The host of database server DATABASE_PORT Yes The port that used by the host
This section will help you to activate and deacivate local environment through CLI.
-
- Windows
env\Scripts\activate
- Unix
source env/bin/activate
- Windows
-
And if you need to close it, then run as easy as run terminated signal:
- Windows/Unix
[CTRL + C]
or you can close it in gracefully way:
- Windows/Unix
deactivate
- Windows/Unix
-
Before you follow these instructions, ensure that you already activated local environment as follow as this section. After that, here are things you need to do.
- Run ngrok to make public url
ngrok http localhost:8000
- Copy the public url the one with https and put it as webhook URL in LINE Bot configuration.
- Run the application
python manage.py runserver
- Exit by triggering a default terminate signal if you already done
[CTRL + C]
- Run ngrok to make public url
-
Assume you already started the application. Here are available commands you could use on this project:
- Make migrations if you edit/create a model
python manage.py makemigrations
- Migrate the model changes you made in database
python manage.py migrate
- Make migrations if you edit/create a model
-
Ensure you already started the application before do these steps:
python manage.py createsuperuser