Python版超市管理系统源代码,基于django+mysql
安装步骤
1、在mysql中创建名为demo_django_supermarket的数据库,修改config/setting.py中数据库用户及密码

CREATE DATABASE demo_django_supermarket DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

2、pip install -r requirements
3、初始化数据库:manage.py migrate
4、设置一个超级管理员 admin (admin@123456)

manage.py loaddata fixtures/root_manager.yaml

5、启动服务

manage.py runserver localhost:8001

完整程序源代码下载地址:Python版超市管理系统源代码
程序运行截图


后台管理


setting.py

"""
Django settings for config project.Generated by 'django-admin startproject' using Django 2.1.4.For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""import os# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '_joao(!w!oc6ktbxr55x4$ioy4$#u6#09cx$st=pp3sj(6lm!)'# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = TrueALLOWED_HOSTS = ['*',# '127.0.0.1',# '10.10.10.154',# '120.229.216.9']# Application definitionINSTALLED_APPS = ['django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','app','gunicorn',
]MIDDLEWARE = ['django.middleware.security.SecurityMiddleware','django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware',
]ROOT_URLCONF = 'config.urls'TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates','DIRS': [BASE_DIR, os.path.join('templates')],'APP_DIRS': True,'OPTIONS': {'context_processors': ['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},
]WSGI_APPLICATION = 'config.wsgi.application'# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databasesDATABASES = {'default': {'ENGINE': 'django.db.backends.mysql','HOST': '127.0.0.1','PORT': '3306','NAME': 'demo_django_supermarket','USER': 'root','PASSWORD': 'sxing86','OPTIONS': {'charset': 'utf8mb4'}}
}# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validatorsAUTH_PASSWORD_VALIDATORS = [{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',},{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',},{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',},{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',},
]# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/LANGUAGE_CODE = 'zh-hans'TIME_ZONE = 'Asia/Shanghai'USE_I18N = TrueUSE_L10N = TrueUSE_TZ = False
# USE_TZ = True  # 时区# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/STATIC_URL = '/static/'STATIC_PATH = os.path.dirname(os.path.abspath(__file__))
STATIC_PATH = os.path.join(STATIC_PATH, '../')STATICFILES_DIRS = (os.path.join(STATIC_PATH, 'static/'),
)MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media')

0001_initial.py

# Generated by Django 2.2.2 on 2022-03-16 18:26from django.db import migrations, modelsclass Migration(migrations.Migration):initial = Truedependencies = []operations = [migrations.CreateModel(name='Goods',fields=[('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),('name', models.CharField(max_length=20)),('sale_price', models.FloatField()),('cost_price', models.FloatField()),('weight', models.FloatField()),('sort', models.IntegerField()),('produce_date', models.DateField()),('limit_date', models.DateField()),('lower', models.FloatField(default=0)),('isDelete', models.BooleanField(default=False)),],),migrations.CreateModel(name='Manager',fields=[('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),('account', models.CharField(max_length=20)),('pwd', models.CharField(max_length=40)),('name', models.CharField(max_length=20)),('gender', models.IntegerField(default=0)),('phone', models.CharField(max_length=11)),('authority', models.IntegerField(default=0)),('isDelete', models.BooleanField(default=0)),],),migrations.CreateModel(name='Message',fields=[('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),('time', models.DateTimeField(auto_now=True)),('type', models.IntegerField()),('content', models.TextField()),('contact', models.CharField(max_length=20)),('name', models.CharField(max_length=20)),('isRead', models.BooleanField(default=False)),],),migrations.CreateModel(name='Provider',fields=[('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),('name', models.CharField(max_length=20)),('address', models.CharField(max_length=40)),('phone', models.CharField(max_length=11)),('isDelete', models.BooleanField(default=False)),],),migrations.CreateModel(name='Record',fields=[('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),('location', models.IntegerField()),('date', models.DateField(auto_now=True)),('purchase_num', models.IntegerField(null=True)),('sale_num', models.IntegerField(null=True)),('withdraw_num', models.IntegerField(null=True)),('goods', models.ForeignKey(on_delete=True, to='app.Goods')),],),migrations.AddField(model_name='goods',name='provider',field=models.ForeignKey(on_delete=True, to='app.Provider'),),]

0002_initial_data.py

# Generated by Django 2.2.2 on 2022-03-16 18:26
import datetime
import os
import random
import shutilfrom django.db import migrationsdef init_manager(apps, args):Manager = apps.get_model('app', 'Manager')Manager(account="admin",pwd="123456",name="admin",gender=1,phone="15512345678",).save()def init_providers(apps, args):provider = apps.get_model('app', 'Provider')for i in range(3):p = provider()p.name = "供应商%d" % ip.address = "(%s)请关注公众号:Python代码大全" % p.namep.phone = "15512345678%d" % ip.save()def init_goods(apps, args):category_map = {0: "零食饮料",1: "生鲜果蔬",2: "粮油副食",3: "清洁用品",4: "家居家电",}# 循环 /static/media/resources/goods/*current_path = os.path.dirname(os.path.abspath(__file__))current_path = current_path.replace("app\migrations", "")resource_img_dir = "%s/static/media/resources/goods" % current_pathupload_img_dir = "%s/static/media/goods_img" % current_pathfiles = [f for f in os.listdir(resource_img_dir) if os.path.isfile(os.path.join(resource_img_dir, f))]print(files)# 复制+改名 成 /static/media/goods_img/{category_num}_{good_id}.jpgdate_now = datetime.datetime.utcnow()good = apps.get_model('app', 'Goods')record = apps.get_model('app', 'Record')for index, f in enumerate(files):category_id = random.randrange(0, 5)provider_id = random.randrange(1, 4)cost_price = random.randrange(5, 100)sale_price = cost_price + random.randrange(5, 20)produce_date = date_now - datetime.timedelta(days=(category_id + 1) * 365)limit_date = date_now + datetime.timedelta(days=(category_id + 1) * 365)purchase_date = produce_date + datetime.timedelta(days=cost_price)sale_date = purchase_date + datetime.timedelta(days=sale_price)# total = good.objects.count()# 随机造数据g = good(name=category_map[category_id] + str(index),sort=category_id,cost_price=float(cost_price),sale_price=float(sale_price),produce_date=produce_date,limit_date=limit_date,weight=float(sale_price + cost_price),provider_id=provider_id,)# g.id = total+1g.save()image_path = "%s/%d_%d.png" % (upload_img_dir, category_id, g.id)shutil.copyfile("%s/%s" % (resource_img_dir, f), image_path)location_id = random.randrange(0, 8)record(location=location_id,purchase_num=sale_price * cost_price,goods_id=g.id,date=purchase_date,).save()record(location=location_id,goods_id=g.id,date=sale_date,sale_num=sale_price * cost_price / (location_id + 1),).save()class Migration(migrations.Migration):dependencies = [('app', '0001_initial'),]operations = [migrations.RunPython(init_providers),migrations.RunPython(init_goods),migrations.RunPython(init_manager),]

完整程序源代码下载地址:Python版超市管理系统源代码

Python版超市管理系统源代码,基于django+mysql相关推荐

  1. Python项目实战:Python版超市管理系统源代码

    Python版超市管理系统可实现下单商品,修改商品数量,删除商品,结算商品. 程序使用元组代表商品,元组的多个元素分别代表商品条码,商品名称,商品单价: 使用dict来表示系统当前仓库中的所有商品,d ...

  2. Python版名片管理系统源代码

    Python版名片管理系统,功能: 新增名片(记录用户的姓名,电话,QQ,邮箱): 显示所有名片: 查询名片: 查询成功后可以修改,删除名片 运行截图: cards_main.py :程序的入口,完整 ...

  3. python车辆定位调度管理系统,基于django+twisted

    通过给车辆安装gps定位器,实现车辆的监控管理 软件架构 软件架构说明 主要框架 python: django twisted 数据库:postgresql 前端:layui 进程守护:supervi ...

  4. Python网上商城源代码,基于Django+MySQL+Redis,支持支付宝付款

    Python网上商城源代码,基于Django+MySQL+Redis,支持支付宝付款,实现:用户登录注册,商品展示,商品详情界面,搜索商品,将不同尺寸颜色数量的商品加入购物车,购物车管理,地址管理,形 ...

  5. 基于Python的超市管理系统毕业设计源码111042

    目  录 摘要 1 绪论 1.1研究背景 1.2研究现状 1.3系统开发技术的特色 1.4论文结构与章节安排 2基于Python的 超市管理系统 系统分析 2.1 可行性分析 2.2 系统流程分析 2 ...

  6. 基于django+mysql的教师教学质量评价系统源代码,教学评价系统源码

    基于django+mysql的教师教学质量评价系统源代码,教学评价系统源码 程序部署方法 1.安装程序依赖: 2.配置settings.py中的DATABASES,并在mysql中创建对应的数据库: ...

  7. Python个人网盘源码、云盘系统源程序,基于Django+Mysql

    Python个人网盘源码.云盘系统源程序,基于Django+Mysql 1.安装依赖 pip install -r requirements.txt 2.检查配置文件,修改邮箱和数据库配置 # myc ...

  8. Python运维管理系统源代码,基于fastapi异步框架

    Python运维管理系统源代码,基于fastapi异步框架 部署方式 创建虚拟环境 python -m venv venv 安装依赖库 pip install -r requirements.txt ...

  9. 计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档

    计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档 计算机毕业设计Java超市管理系统(源码+系统+mysql数据库+lw文档) 本源码技术栈: 项目架构:B/S架构 开发语言 ...

最新文章

  1. 如何使用有限的数据来训练 GANs?
  2. c++ 高通、低通、带通滤波器_射频/微波滤波器
  3. pthread_mutex_lock的thread特性
  4. Android:30分钟弄明白Touch事件分发机制
  5. 【设计模式】迪米特法则和六种原则的总结
  6. 带你理清 Java 混乱的日志体系 - log4j、logback、log4j2、jcl、SLFJ 究竟是啥关系?
  7. PAT甲级 -- 1007 Maximum Subsequence Sum (25 分)
  8. mysql横向扩展_高可用MySQL学习笔记-面向横向扩展的MYSQL复制
  9. C#遍历文件夹下所有文件
  10. tornado celery mysql_tornado中使用celery实现异步MySQL操作
  11. Google Earth Engine——Landsat (数据介绍)GEE数据到底是否满足几何和辐射校正?
  12. 2022-2027年中国电动汽车充电站及充电桩行业市场深度分析及投资战略规划报告
  13. Linux 如何查看文件夹的大小(du、df、ls、find)
  14. 手机传感器数据导出_旧手机先别扔丨简单改造秒变黑科技监测器
  15. 2015校园O2O商业模式解析——从物流切入
  16. Unity5.联机笔记
  17. 微信小程序小技巧系列《一》幻灯片,tab导航切换
  18. 什么是串扰crosstalk
  19. Python词云实现
  20. Python语法对空格的严格要求

热门文章

  1. 第一课_不白如何选够电脑
  2. 南昌-婺源-景德镇攻略
  3. 固定资产管理系统实施后的效果
  4. 解决KEIL MDK中JLINK烧录代码时提示the connected jlink is defective问题
  5. 数字图像处理_冈萨雷斯_一些重要的标准数组
  6. android反编译后有中文乱码,android反编译查看源码,apk解压后XML乱码解决
  7. 乱评“神泣·shaiya”
  8. Linux操作系统学习笔记(二十八)深入理解CPU
  9. 计算机与汉字+输入速度+云输入法,影响速录系统速度的因素
  10. spring boot 事务_一个基于 RabbitMQ 的可复用的分布式事务消息架构方案!