Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

lazy-assedninja/Django-WhatToEat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django-WhatToEat

Refactor the university project.

Environment

  • Ubuntu 16.04.7 LTS
  • MySQL Client 14.14
  • MySQL Server 5.7.3-log
  • Python 3.7.10 (line-bot-sdk require version >= 3.6)

Virtual Environment

To avoid the following error when creating virtual environment on Ubuntu:

The virtual environment was not created successfully because ensurepip is not available.  On Debian/Ubuntu systems, you need to install the python3-venv package using the following command.
   apt install python3-venv
You may need to use sudo with that command.  After installing the python3-venv package, recreate your virtual environment.
Error: Command '['/home/eddie/Slask/tmp/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

Install the python3-venv package and use the virtualenv command instead, virtualenv called venv:

sudo apt install python3-venv python-virtualenv
virtualenv --python=python3.7 venv

Start your virtual environment:

source venv/bin/activate

Install MySQL developing packages:

sudo apt-get install libmysqlclient-dev python-dev

Install packages with requirements:

pip install -r requirements.txt

Configurations

To use python-dotenv, create the .env file, it can include various server parameters.

SECRET_KEY = 'SECRET_KEY'
ALLOWED_HOSTS = '*'

DB_ENGINE = 'django.db.backends.mysql'
DB_NAME = 'DB_NAME'
DB_USER = 'DB_USER'
DB_PASSWORD = 'DB_PASSWORD'
DB_HOST = 'localhost'
DB_PORT = '3306'

LINE_CHANNEL_ACCESS_LONG_TOKEN = 'LINE_CHANNEL_ACCESS_LONG_TOKEN'
LINE_CHANNEL_SECRET = 'LINE_CHANNEL_SECRET'

Run

You need to be in the directory that contains the manage.py file, execute the following command to start the server:

python3 manage.py runserver