# b2c_python **Repository Path**: admin_yys/b2c_python ## Basic Information - **Project Name**: b2c_python - **Description**: 基于Django的一个电商系统 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2021-12-09 - **Last Updated**: 2025-01-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # b2c_python #### 介绍 一个Python web毕设项目,基于django框架搭建。 #### 软件环境 - Python 3.10.0 - Django 3.2.9 - MySQl 8.0.26 - Redis 3.2.100 #### 软件架构 - b2c_system 根模块 - models 模型模块 - store 商城模块 - store_admin 后台管理模块 #### 运行环境安装 - Python安装 - 官网:[https://www.python.org/](https://gitee.com/link?target=https%3A%2F%2Fwww.python.org%2F) - windows32位下载地址:[https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe](https://gitee.com/link?target=https%3A%2F%2Fwww.python.org%2Fftp%2Fpython%2F3.10.0%2Fpython-3.10.0-amd64.exe) - windows64位下载地址:[https://www.python.org/ftp/python/3.10.0/python-3.10.0.exe](https://gitee.com/link?target=https%3A%2F%2Fwww.python.org%2Fftp%2Fpython%2F3.10.0%2Fpython-3.10.0.exe) - Django安装 ``` # 安装最新版本的Django pip install django # 安装指定版本的Django pip install -v django==2.0(版本号) # 查看安装好的Django版本 python -m django --version ``` - MySQL安装 - 压缩版下载地址:[https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.26-winx64.zip](https://gitee.com/link?target=https%3A%2F%2Fdownloads.mysql.com%2Farchives%2Fget%2Fp%2F23%2Ffile%2Fmysql-8.0.26-winx64.zip) - 安装版下载地址:[https://downloads.mysql.com/archives/get/p/25/file/mysql-installer-community-8.0.26.0.msi](https://gitee.com/link?target=https%3A%2F%2Fdownloads.mysql.com%2Farchives%2Fget%2Fp%2F25%2Ffile%2Fmysql-installer-community-8.0.26.0.msi) - 安装教程:https://blog.csdn.net/weixin_45653816/article/details/115110589 - Redis安装 - 下载地址:https://github.com/microsoftarchive/redis/releases - 安装教程:https://www.cnblogs.com/ellisonzhang/p/14119077.html - 安装 Python Redis依赖 ```sh pip install django-redis ``` - 安装 Python Mysql依赖 ```sh pip install mysqlclient # 检查安装 python import MySQLdb # 不报错就是安装成功 ``` #### 创建数据库 ``` create database b2c_db; ``` #### 修改数据库配置 ```python # /b2c_system/b2c_system/settings.py # MySQL数据库配置 DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'b2c_db', 'USER': 'root', 'PASSWORD': '123456', 'HOST': '127.0.0.1', 'PORT': '3306' } } # redis配置 CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", "CONNECTION_POOL_KWARGS": {"max_connections": 100}, # "PASSWORD": "密码", "DECODE_RESPONSES": True } } } ``` #### 初始化数据表 ```sh cd /d2c_python python manage.py makemigrations python manage.py migrate ``` #### 初始化表记录 ```sql #连接到mysql数据库,执行以下语句 use b2c_db; # 初始化管理员 # 用户名 admin # 密码 admin # 昵称 超级管理员 insert into system_user (user_name,user_pass,nick_name) value('admin','21232f297a57a5a743894a0e4a801fc3','超级管理员') # 初始化菜单 INSERT INTO `system_menu` VALUES (1,'系统管理','#','1',0),(2,'用户管理','/admin/user','2',1),(3,'菜单管理','/admin/menu','2',1),(4,'商城管理','#','1',0),(5,'客户管理','/admin','2',4),(6,'商品管理','/admin','2',4),(7,'测试目录','#','1',0),(8,'测试菜单','/','2',7),(9,'测试菜单2','/admin','2',0); ``` #### 启动项目 ```sh cd /d2c_python python manage.py runserver [端口号] ```