python趣味编程-使用 Django 的 Python 库存管理系统
发布时间
阅读量:
阅读量

在 Python 中使用 Django 的库存管理系统
该项目的名称为库存管理系统 。这是一个基于网络的应用程序,可帮助特定企业或商店在线管理其库存或库存。该项目允许企业管理层轻松存储、记录、监控他们的产品库存。它是使用 Django 框架用 Python 开发的。它具有使用 Bootstrap 版本 5 的简单且令人愉快的用户界面。该项目还具有用户友好的特性和功能
关于库存管理系统
我使用以下内容开发了这个项目:
- Python
- 姜戈
- 超文本标记语言
- CSS
- JavaScript
- jQuery
- 阿贾克斯
- 引导程序 v5
- 材料设计引导模板
- 字体真棒
该库存管理系统项目 仅供企业或商店管理人员访问。该系统可以由管理员和工作人员 2 个用户访问。管理员有权访问 Django 的管理面板/站点并管理用户列表。员工用户仅被允许管理该站点。在这个项目中,用户可以存储或列出产品类别并列出产品。用户可以为每个产品添加库存,系统会自动计算每个产品的可用库存。该应用程序还包含销售交易功能,用户可以对客户的所有交易进行编码。销售交易中的每件商品都会自动从可用库存中扣除。用户还可以跟踪产品库存的历史记录。
特征
- 登录和注册页面
- 主页/仪表板页面 * 显示摘要
- 类别 * 添加新类别
- 列出所有类别
- 更新类别详细信息
- 删除类别详细信息
- 产品 * 添加新产品
- 列出所有产品
- 更新产品详细信息
- 删除产品详细信息
- 存货 * 列出所有产品
- 查看产品库存历史记录
- 添加新产品库存
- 更新产品库存
- 删除产品库存
- 销售交易
- 发票 * 列出所有发票
- 删除发票详细信息
- 轮廓 * 更新个人资料详细信息
- 更新账户密码
- 登出
快照示例
登录页面

主页

类别页

产品列表

存货

产品库存历史

销售交易表格

发票清单

如何运行
下载/安装以下内容
- Python ( 我用的是v3.9.1 )
- Django ( 我用的是v4.0.3 )
- PIP ( 用于 python 模块安装 )
设置/安装
- 下载 并解压 提供的源代码
zip文件。 (下载按钮位于下方) - 由于文件夹超出了网站的最大文件大小,静态文件单独上传。下载静态文件 @https://www.dropbox.com/s/5csn2jsonu7if3z/static.zip?dl=1。将静态文件解压到下载的源代码文件夹的根路径下。
- 打开 终端**/命令提示符** 窗口。 (确保在环境变量中添加“python”和“pip”)
- 将工作目录 更改为 提取的源代码文件夹。 IE
cd C:\Users\Personal-23\Desktop\django_ims - 运行 以下命令 :
pip install Djangopip install -r requirements.txtpython manage.py migratepython manage.py runserver
- 打开****网络浏览 器并浏览
http://localhost:8000/或http://127.0.0.1:8000/
注意:我可能会忘记列出一些其他模块/库。如果出现任何缺失的模块,请安装。
访问信息
超级
用户 用户名:admin
密码:admin123
部分源码
unit_price={}
description={}
stock={}
try:
details = open("stock.txt","r")
no_items = int((details.readline()).rstrip("\n"))
for i in range(0,no_items):
line = (details.readline()).rstrip("\n")
x1,x2 = line.split("#")
x1=int(x1)
x2=float(x2)
unit_price.update({x1: x2})
for i in range(0,no_items):
line = (details.readline()).rstrip("\n")
x1,x2 = line.split("#")
x1=int(x1)
description.update({x1: x2})
for i in range(0,no_items):
line = (details.readline()).rstrip("\n")
x1,x2 = line.split("#")
x1=int(x1)
x2=int(x2)
stock.update({x1: x2})
except:
print("Stock empty")
finally:
details.close()
cart=[]
c="y"
print("Welcome to Inventory Management System")
print()
print("A-Add an item")
print("R-Remove an item")
print("E-Edit specifics of an item")
print("L-List all items")
print("I-Inquire about a item")
print("P-Purchase")
print("C-Checkout")
print("S-Show all items purchased")
print("Q-Quit")
print("remove-Remove an item from the cart")
print("help-See all commands again")
print()
total_cost=0
flag=0
while(c!= "q" or c!= "Q"):
c= input("What would you like to do? ")
if(c=="q" or c=="Q"):
break
elif(c=="A" or c=="a"):
p_no = int(input("Enter item number: "))
p_pr = float(input("Enter item price: "))
p_desc = input("Enter item description: ")
p_stock = int(input("Enter item stock: "))
m=0
for i in range(0,len(unit_price)):
if(p_no in unit_price):
p_no+=1
m=1
if(m==1):
print()
print("That item number already exists :(, changing value to ",p_no)
unit_price.update({p_no: p_pr})
description.update({p_no: p_desc})
if(p_stock > -1):
stock.update({p_no: p_stock})
else:
p_stock = 0
stock.update({p_no: p_stock})
print("The stock of an item cannot be negative, the stock has been set to 0.")
print()
print("Item number: ",p_no," Description: ",description.get(p_no)," Price: ",unit_price.get(p_no)," Stock: ",stock.get(p_no))
print("Item was added successfully!")
print()
elif(c=="E" or c=="e"):
print()
p_no = int(input("Enter item number: "))
if(p_no in unit_price):
p_pr = float(input("Enter item price: "))
p_desc = input("Enter item description: ")
p_stock = int(input("Enter item stock: "))
unit_price.update({p_no: p_pr})
description.update({p_no: p_desc})
stock.update({p_no: p_stock})
else:
print("That item does not exist, to add an item use a")
print()
elif(c=="R" or c=="r"):
print()
p_no = int(input("Enter item number: "))
if(p_no in unit_price):
are_you_sure = input("Are you sure you want to remove that item(y/n)? ")
if(are_you_sure=="y" or are_you_sure=="Y"):
unit_price.pop(p_no)
description.pop(p_no)
stock.pop(p_no)
print("Item successfully removed!")
print()
else:
print("Sorry, we don't have such an item!")
print()
elif(c=="L" or c=="l"):
print()
print("Item and their prices: ",unit_price)
print("Descriptions: ",description)
print("Stock left of Item: ",stock)
print()
elif(c=="I" or c=="i"):
print()
p_no=int(input("Enter Item Number: "))
if(p_no in unit_price):
print()
print("Item number: ",p_no," Description: ",description.get(p_no)," Price: ",unit_price.get(p_no)," Stock: ",stock.get(p_no))
if(stock.get(p_no)<3 and stock.get(p_no)!=0):
print("Only ",stock.get(p_no)," remaining! Hurry!")
print()
else:
print("Sorry we don't have such an item!")
print()
elif(c=="P" or c=="p"):
print()
p_no = int(input("Enter Item number: "))
if(p_no in unit_price):
if(flag==1):
flag=0
stock_current = stock.get(p_no)
if(stock_current>0):
stock_current = stock.get(p_no)
stock[p_no] = stock_current-1
item_price = unit_price.get(p_no)
total_cost = total_cost+item_price
print(description.get(p_no),"added to cart: ","$",item_price)
cart.append(p_no)
else:
print("Sorry! We don't have that item in stock!")
else:
print("Sorry! We don't have such an item!")
print()
elif(c=="C" or c=="c"):
print()
print("You bought the following items: ",cart)
print("Total: ","$",round(total_cost,2))
tax= round(0.12*total_cost,2)
print("Tax is 12%: ","$",tax)
total = round(total_cost+tax,2)
print("After Tax: ","$",total)
total_cost=0
flag=1
print()
print("You can still purchase items after check out, your cart has been reset. To quit press q")
print()
elif(c=="help"):
print()
print("Help Centre")
print("A-Add an item")
print("R-Remove an item")
print("E-Edit specifics of an item")
print("L-List all items")
print("I-Inquire about a item")
print("P-Purchase")
print("C-Checkout")
print("S-Show all items purchased")
print("remove-Remove an item from the cart")
print("help-See all commands again")
print("If you have any other questions or concerns please contact the manager.")
print()
elif(c=="remove" or c=="Remove"):#To remove an item from the cart
print()
are_you_sure = input("Are you sure you want to remove an item from the cart(y/n)? ")
if(are_you_sure=="y"):
p_no = int(input("Enter item number to remove from cart: "))
if(p_no in cart):
stock_current = stock.get(p_no)
stock[p_no] = stock_current+1
item_price = unit_price.get(p_no)
total_cost = total_cost-item_price
j=0
for i in range(0,len(cart)):
if(i==p_no):
j=i
cart.pop(j)
print(description.get(p_no),"removed from cart: ")
print()
else:
print()
print("That item is not in your cart!")
print()
elif(c=="s" or c=="S"):
print()
print(cart)
print()
else:
print()
print("ERROR! Contact manager for help!")
print()
if(total_cost>0 and flag==0):
print()
print("You bought: ",cart)
print("Total: ","$",round(total_cost,2))
tax= round(0.12*total_cost,2)
print("Tax is 12%: ","$",tax)
total = round(total_cost+tax,2)
print("After Tax: ","$",total)
print("Thank you for using Inventory Management System")
try:
details = open("stock.txt","w")
no_items=len(unit_price)
details.write(str(no_items)+"\n")
for i in range(0,no_items):
details.write(str(i+1)+"#"+str(unit_price[i+1])+"\n")
for i in range(0,no_items):
details.write(str(i+1)+"#"+description[i+1]+"\n")
for i in range(0,no_items):
details.write(str(i+1)+"#"+str(stock[i+1])+"\n")
except:
print("Stock saved")
finally:
details.close()
代码解读
就是这样!我希望这能帮助您找到您正在寻找的东西。也许您会发现这个库存管理系统 很有用,并且可以帮助您完成未来的Python Django 项目 。
在此网站上探索更多免费源代码和教程。
<>
全部评论 (0)
还没有任何评论哟~
