Skip to content

jtmyd-top/demo-django-supermarket

 
 

Repository files navigation

demo-django-supermarket

毕业设计 (2019)

环境配置 (Ubuntu 18.04)

数据库 (mysqlclient)

  1. 系统需要装好 default-libmysqlclient-dev
> sudo apt-get install default-libmysqlclient-dev python3.7 python3.7-dev
  1. pip 升级

参考
https://stackoverflow.com/a/64095095

> pip3 install -U pip
> pip3 install -U setuptools
  1. pip3 install mysqlclient
  2. 本机安装好 mysql 服务并启动 sudo /etc/init.d/mysql start
  3. 使用/创建用户 admin, 使用创建数据库 demo_django_supermarket (root权限下)
    • 创建数据库
    mysql> CREATE DATABASE demo_django_supermarket DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    • 检查数据库默认编码
    mysql> USE demo_django_supermarket;
    mysql> SELECT @@character_set_database, @@collation_database;
    +--------------------------+----------------------+
    | @@character_set_database | @@collation_database |
    +--------------------------+----------------------+
    | utf8mb4                  | utf8mb4_unicode_ci   |
    +--------------------------+----------------------+
    1 row in set (0.00 sec)
    
    mysql> SHOW TABLE STATUS FROM demo_django_supermarket;
    (略)
    • 创建数据库连接用户并授权
    mysql> CREATE USER 'admin'@'localhost' IDENTIFIED BY '123456';
    mysql> GRANT ALL PRIVILEGES ON demo_django_supermarket.* TO 'admin'@'localhost';

初始化数据

  1. migrate 迁移/初始化数据库
> python3 manage.py makemigrations
> python3 manage.py migrate
  1. 设置一个超级管理员 admin (admin@123456)

参考 https://docs.djangoproject.com/en/4.0/howto/initial-data/

> python3 manage.py loaddata fixtures/*

开始

  1. 启动服务
> python3 manage.py runserver localhost:8001

若启动以 0.0.0.0:8001 还能在局域网内的其他设备访问

TODO

  • 使用 docker 来启动 mysql 和本服务
  • fixture/migrate 增加初始化商品数据的
  • migrate 增加模拟销售数据
  • 接口文档 wiki
  • 测试开发环境配置(换一个机器重新开发)
  • 测试用例

About

毕业设计-超市管理系统(django)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.4%
  • JavaScript 1.3%
  • CSS 1.3%