• 【毕业设计】 基于Django的图书管理系统


    1 前言

    Hi,大家好,这里是丹成学长,今天向大家介绍 一个python web项目

    基于Django的图书管理系统

    大家可用于 毕业设计


    计算机毕设选题大全及项目分享:

    https://blog.csdn.net/WEB_DC/article/details/125563252


    2 背景意义

    根据各图书销售门店的调查可知,随着销售规模的不断壮大,经营的图书品种、数量也逐渐增多。在图书销售不断发展的同时,其常年采用的传统的人工方式管理暴露了一些问题。例如,查找读者借阅的某本图书的具体详细信息需要靠人工记忆在书海中苦苦查找,由于图书储存量大,很难准确定位图书的具体位置,因此每天都要浪费大量宝贵的时间资源。为提高工作效率,同时摆脱图书管理人员在工作中出现的种种弊端,现委托某单位开发一个图书管理系统。

    3 功能需求

    系统主要是管理员对图书信息和出版社进行管理。本系统需要有出版社管理、图书管理、作者管理、统计等功能,能将相关信息从数据库中添加修改删除并且利用查询将相关信息显示出来。数据要求有自动更新功能,能显示最新的结果。根据学校图书馆管理系统的特点,可以将其分为图书信息管理,出版社管理,作者管理,系统管理等4个部分,其中各个部分及其包括的具体功能模块如图所示。

    在这里插入图片描述

    4 技术栈

    • 服务端:Python 3.8

    • Web框架:Django 3.2

    • 数据库:MySQL mysql-8.0.13-winx64

    • 前端: Bootstrap4

    • IDE: Pycharm

    5 实现效果

    各模块功能页面

    出版社管理, 列表显示
    在这里插入图片描述
    ​新增出版社

    在这里插入图片描述

    编辑出版社:

    在这里插入图片描述

    ​作者管理, 列表显示:
    在这里插入图片描述

    新增作者:
    在这里插入图片描述

    登录页面:
    在这里插入图片描述

    注册页面:
    在这里插入图片描述

    6 项目架构

    在这里插入图片描述

    7 数据库表设计

    结合实际情况及对用户需求的分析,图书管理系统bms数据库主要包含如下表所示的4个数据表。

    7.1 出版社信息表

    在这里插入图片描述

    7.2 图书信息表

    在这里插入图片描述

    7.3 作者信息表

    在这里插入图片描述

    7.4 用户信息表

    在这里插入图片描述

    8 部分代码实现讲解

    8.1 出版社新增

    创建新增出版社视图函数

    # 添加出版社
    def add_publisher(request):
        if request.method == 'POST':
            new_publisher_name = request.POST.get('name')
            new_publisher_addr = request.POST.get('addr')
            models.Publisher.objects.create(name=new_publisher_name, addr=new_publisher_addr)
            return redirect('/pub_list/')
        return render(request, 'pub_add.html')
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    修改ulrs.py 映射关系

    urlpatterns = [
        path('admin/', admin.site.urls),
        url(r'^pub_list/', views.publisher_list),      # 出版社列表
        url(r'^add_pub/', views.add_publisher),     # 新增出版社
    ]
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    新建pub_add.html页面用于新增出版社

    <div class="col-md-10">
                <div class="content-box-large">
                    <div class="panel-heading">
                        <div class="panel-title">新增出版社</div>
                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal" role="form" action="/add_pub/" method="post">
                            {% csrf_token %}
                            <div class="form-group">
                                <label for="inputEmail3" class="col-sm-2 control-label">出版社名称</label>
                                <div class="col-sm-10">
                                    <input class="form-control" id="inputEmail3" placeholder="出版社名称" name="name">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">出版社地址</label>
                                <div class="col-sm-10">
                                    <textarea class="form-control" placeholder="出版社地址" rows="3" name="addr"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="submit" class="btn btn-primary">保存</button>
                                    <button type="submit" formmethod="get" formaction="/pub_list" class="btn btn-default">返回</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30

    8.2 作者管理功能实现

    参照出版社管理最终实现代码和页面展示如下:

    创建新增,展示,修改,删除作者视图函数

    # 作者的列表
    def author_list(request):
        author = models.Author.objects.all()
        return render(request, 'auth_list.html', {'author_list': author})
     
     
    # 添加作者
    def add_author(request):
        if request.method == 'POST':
            new_author_name = request.POST.get('name')
            new_author_sex = request.POST.get('sex')
            new_author_age = request.POST.get('age')
            new_author_tel = request.POST.get('tel')
            models.Author.objects.create(name=new_author_name, sex=new_author_sex, age=new_author_age, tel=new_author_tel)
            return redirect('/author_list/')
        return render(request, 'author_add.html')
     
     
    # 删除作者
    def drop_author(request):
        drop_id = request.GET.get('id')
        drop_obj = models.Author.objects.get(id=drop_id)
        drop_obj.delete()
        return redirect('/author_list/')
     
     
    # 修改作者
    def edit_author(request):
        if request.method == 'POST':
            edit_id = request.GET.get('id')
            edit_obj = models.Author.objects.get(id=edit_id)
            new_author_name = request.POST.get('edit_name')
            new_author_sex = request.POST.get('edit_sex')
            new_author_age = request.POST.get('edit_age')
            new_author_tel = request.POST.get('edit_tel')
            new_book_id = request.POST.getlist('book_id')
            edit_obj.name = new_author_name
            edit_obj.sex = new_author_sex
            edit_obj.age = new_author_age
            edit_obj.tel= new_author_tel
            edit_obj.book.set(new_book_id)
            edit_obj.save()
            return redirect('/author_list/')
        edit_id = request.GET.get('id')
        edit_obj = models.Author.objects.get(id=edit_id)
        all_book = models.Book.objects.all()
        return render(request, 'auth_edit.html', {
            'author': edit_obj,
            'book_list': all_book
        })
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50

    修改ulrs.py 映射关系

    urlpatterns = [
        path('admin/', admin.site.urls),
        url(r'^$', views.publisher_list),
        url(r'^pub_list/', views.publisher_list),      # 出版社列表
        url(r'^add_pub/', views.add_publisher),     # 新增出版社
        url(r'^edit_pub/', views.edit_publisher),     # 编辑出版社
        url(r'^drop_pub/', views.drop_publisher),     # 删除出版社
        url(r'^author_list/', views.author_list),     # 作者列表
        url(r'^add_author/', views.add_author),    # 新增作者
        url(r'^drop_author/', views.drop_author),    # 删除作者
        url(r'^edit_author/', views.edit_author),    # 编辑作者
    ]
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    计算机毕设选题大全及项目分享:

    https://blog.csdn.net/WEB_DC/article/details/125563252


    9 最后

  • 相关阅读:
    EasyX趣味化编程note6,图片操作及文字
    如何实现图片预加载和加载进度条
    聊聊领导力与带团队的那些事
    【CLR C#】面向面试的.Net的GC(垃圾回收)机制及其整体流程
    2022.11.24
    java毕业生设计学生学籍信息管理系统计算机源码+系统+mysql+调试部署+lw
    图文详解Linux基础经典教程(06)——CentOS安装JDK
    游戏里的猎头
    gulp入门1-安装
    垃圾收集器G1和ZGC、颜色指针(思维导图)
  • 原文地址:https://blog.csdn.net/WEB_DC/article/details/125613775