Computer graduation project Python+django online home textile mall (source code + system +mysql database +Lw document)

Project introduction

This paper mainly discusses how to use DJANGO language to develop an online home textile mall. This system will strictly follow the software development process for all stages of work, using B/S architecture, object-oriented programming ideas for project development. In the introduction, the author will discuss the current background of online home textile mall and the purpose of system development. The subsequent chapters will analyze and design the system in each stage in strict accordance with the software development process.
The main users of online home textile mall are divided into administrators and members. The functions include administrators: home page, personal center, member management, commodity category management, commodity information management, commodity inventory management, warehouse out record management, warehouse in record management, sales statistics management, contact us management, message board management, system management, order management; Members: homepage, personal center, my collection management, order management and other functions. Because the functional module design of this website is relatively comprehensive, the whole process of information management of online home textile mall can be realized.

development environment

Computer graduation project Python+django online home textile mall (source code + system +mysql database +Lw document)
Development language: Python
python framework: django
Software version: python3.7/python3.8
Database: mysql 5.7 or later
Database tool: Navicat11
Development software: PyCharm/vs code
Front end frame: vue.js
Developable framework: ssm/Springboot/vue/python/PHP/ Applet / Android can be developed

System screenshot





Commodity inventory management: in the commodity inventory management page, you can perform detailed, outbound, inbound, modify or delete operations on the index, number, name, category, quantity, update and other information

critical code

def huiyuan_register(request):
    if request.method in ["POST", "GET"]:
        msg = {'code': normal_code, "msg": mes.normal_code}
        req_dict = request.session.get("req_dict")

        error = huiyuan.createbyreq(huiyuan, huiyuan, req_dict)
        if error != None:
            msg['code'] = crud_error_code
            msg['msg'] = "User already exists,Do not re register!"
        return JsonResponse(msg)

def huiyuan_login(request):
    if request.method in ["POST", "GET"]:
        msg = {'code': normal_code, "msg": mes.normal_code}
        req_dict = request.session.get("req_dict")

        datas = huiyuan.getbyparams(huiyuan, huiyuan, req_dict)
        if not datas:
            msg['code'] = password_error_code
            msg['msg'] = mes.password_error_code
            return JsonResponse(msg)

        req_dict['id'] = datas[0].get('id')
        return Auth.authenticate(Auth, huiyuan, req_dict)


def huiyuan_logout(request):
    if request.method in ["POST", "GET"]:
        msg = {
            "msg": "Login successful",
            "code": 0
        }

        return JsonResponse(msg)


def huiyuan_resetPass(request):
    '''
    '''
    if request.method in ["POST", "GET"]:
        msg = {"code": normal_code, "msg": mes.normal_code}

        req_dict = request.session.get("req_dict")

        error = huiyuan.updatebyparams(huiyuan,huiyuan, req_dict)

        if error != None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return JsonResponse(msg)



def huiyuan_session(request):
    '''
    '''
    if request.method in ["POST", "GET"]:
        msg = {"code": normal_code,"msg": mes.normal_code, "data": {}}

        req_dict={"id":request.session.get('params').get("id")}
        msg['data']  = huiyuan.getbyparams(huiyuan, huiyuan, req_dict)[0]

        return JsonResponse(msg)



def huiyuan_page(request):
    '''
    '''
    if request.method in ["POST", "GET"]:
        msg = {"code": normal_code, "msg": mes.normal_code,  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}
        req_dict = request.session.get("req_dict")

        #Get all column names
        columns=  huiyuan.getallcolumn( huiyuan, huiyuan)

        #Current login user's table
        tablename = request.session.get("tablename")
        #When the column attribute authTable has a value (a user table) [the column name of the column must be consistent with the login field name of the user table], then the corresponding table has a hidden attribute authTable of "yes", then the user can only view his own when viewing the table information
        try:
            __authTables__=huiyuan.__authTables__
        except:
            __authTables__=None

        if __authTables__!=None and  __authTables__!={}:

            for authColumn,authTable in __authTables__.items():
                if authTable==tablename:
                    params = request.session.get("params")
                    req_dict[authColumn]=params.get(authColumn)
                    break

            #authColumn=list(__authTables__.keys())[0]
            #authTable=__authTables__.get(authColumn)

            # if authTable==tablename:
                #params = request.session.get("params")
                #req_dict[authColumn]=params.get(authColumn)

        '''__authSeparate__This attribute is true, params add to userid,Background only queries personal data'''
        try:
            __authSeparate__=huiyuan.__authSeparate__
        except:
            __authSeparate__=None

        if __authSeparate__=="yes":
            tablename=request.session.get("tablename")
            if tablename!="users" and 'userid' in columns:
                try:
                    req_dict['userid']=request.session.get("params").get("id")
                except:
                    pass

        #When the item attribute hashmessage is "yes", the generation system automatically generates the table messages of the message board. At the same time, the table attribute hashmessage of the table is also set to "yes", and the fields include userid (user id), username (user name), content (message content), reply (reply)
        #The interface page needs to distinguish permissions. Ordinary users can view their own messages and reply records, and administrators can view all messages and reply records
        try:
            __hasMessage__=huiyuan.__hasMessage__
        except:
            __hasMessage__=None
        if  __hasMessage__=="yes":
            tablename=request.session.get("tablename")
            if tablename!="users":
                req_dict["userid"]=request.session.get("params").get("id")



        # Judge the table attribute isAdmin of the current table. If it is true, it is the administrator table
        # When the table attribute isAdmin= "yes", the user table printed out is also an administrator, that is, page and list can view everyone's exam records (applied to other tables at the same time)
        __isAdmin__ = None

        allModels = apps.get_app_config('main').get_models()
        for m in allModels:
            if m.__tablename__==tablename:

                try:
                    __isAdmin__ = m.__isAdmin__
                except:
                    __isAdmin__ = None
                break

        # The current table is also a table with administrator permissions
        if  __isAdmin__ == "yes" and req_dict.get("userid"):
            del req_dict["userid"]
        else:
            #For the table with non administrator permissions, judge whether the field name of the current table has userid
            if tablename!="users" and "userid" in huiyuan.getallcolumn(huiyuan,huiyuan):
                req_dict["userid"] = request.session.get("params").get("id")


        msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
        msg['data']['pageSize']  =huiyuan.page(huiyuan, huiyuan, req_dict)

        return JsonResponse(msg)

Tags: Vue Python Database Django

Posted by noisenet on Tue, 09 Aug 2022 17:14:07 +0930