-
Create Django Project
django-admin startproject mysql_restaurant
-
Create the database
CREATE DATABASE django_mysql_restaurant; CREATE USER 'restaurant'@'localhost' IDENTIFIED BY 'restaurant'; GRANT ALL PRIVILEGES ON django_mysql_restaurant.* TO 'restaurant'@'localhost'; FLUSH PRIVILEGES;
show grants for 'restaurant'@'localhost';
+---------------------------------------------------------------------------+ | Grants for restaurant@localhost | +---------------------------------------------------------------------------+ | GRANT USAGE ON . TOrestaurant
@localhost
| | GRANT ALL PRIVILEGES ONdjango_restaurant
.* TOrestaurant
@localhost
| +---------------------------------------------------------------------------+
-
Setting the database credentials
DATABASES = { 'default': { 'ENGINE' : 'django.db.backends.mysql', 'NAME' : 'django_mysql_restaurant', 'USER' : 'restaurant', 'PASSWORD': 'restaurant', 'HOST' : 'localhost', 'PORT' : '3306', } }
-
Run the server
python manage.py runserver ... django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module. Did you install mysqlclient?
-
Modify init.py file by adding this
import pymysql pymysql.install_as_MySQLdb()
-
Re Run the server
python manage.py runserver ... raise RuntimeError("cryptography is required for sha256_password or caching_sha2_password") RuntimeError: cryptography is required for sha256_password or caching_sha2_password
-
Install cryptography
pip install cryptography
-
Re Run the server
python manage.py runserver ... Starting development server at http://127.0.0.1:8000/
-
Create user table
python manage.py migrate
-
Create superuser
python manage.py createsuperuser
> python manage.py startapp meals
> create Meals model
> register Meals model to admin.py
> create human readabe word using class Meta
> displaying name as name, NOT as an object in admin panel
> import slugify to the model
> add slug to the Meals model
> add slug def to the model
> Add static media root dir to settings
> Import settings, static file to project's url
> include the meals's url to project url
> define urlpatterns in meals's url
> create template/Meals/list.html in meals
> def in views to display the list.html
> in views add mail_detail
> in url add the path using slug
> create detail.html in Template/Meals
> display the detail meal
> add static files
> add template and base html
> add list html (ex index.html)
> load static files
> use block to use base.html and list.html
> load css and js
> add detail.html page
> display meal detail
> create Category model
> add Category as FK in Meals model
> create class Meta
> create human readable Category
> add category to views as part of meal_list
> create reservation app
> add to reservation: templates/Reservation/reservation.html
> register the new app
> create Reservation model
> register reservation in admin
> migrations and migrate + check the result in admin + test it out
> add to views
> create a new urls.py + app_name = 'reservation'
> add route path in main urls.py