A travel planner website UI integrated with PostgreSQL. User can register and sign in.
- register, login, logout
- search for tours
- book tours
- login, logout
- check own schedule & details of a tour he/she is responsible for
(source code的tables)
-
download PostgreSQL 14 and pgAdmin (GUI介面)
-
Open pgAdmin4,在PostgreSQL/Database按右鍵 -> Create Database -> 命名為
DB_travel
-
在
DB_travel
按右鍵,選Query Tool按下左上角資料夾按鈕(Open file),在跳出的視窗中選取
db.sql
的路徑,按右下角Select在 Query Editor 中會自動出現新增資料與表格的queries,按下右上角的 Run 按鈕來執行。完成後Refresh Schema,即可看到所有表格
-
為了在新增資料時,postgresql能夠依據已匯入的資料id來生成新id,需在Query Editor輸入以下指令並執行。
SELECT setval('accounts_member_id_seq', (SELECT MAX(id) from public.accounts_member)); SELECT setval('accounts_guide_id_seq', (SELECT MAX(id) from public.accounts_guide)); SELECT setval('travelloapp_tour_id_seq', (SELECT MAX(id) from public.travelloapp_tour)); SELECT setval('calc_order_id_seq', (SELECT MAX(id) from public.calc_order)); SELECT setval('calc_tourist_id_seq', (SELECT MAX(id) from public.calc_tourist));
-
Open travello/settings.py, use the correct 'PASSWORD' in DATABASES.
All are done in the root directory
-
set virtual environment
# for windows pip install virtualenv py -3 -m venv .venv .venv\scripts\activate
# for mac(不確定是不是這樣) pip install virtualenv virtualenv venv source venv/bin/activate
-
install packages
pip install -r requirements.txt # OR python -m pip install -r requirements.txt
-
start server
python manage.py makemigrations python manage.py migrate python manage.py runserver # https://127.0.0.1:8000 in your browser
python manage.py createsuperuser
- Set username & password as you like
- Go to http://127.0.0.1:8000/admin/ Add some testing data and check in pgAdmin to see if the tables have updated some new rows.