Code Monkey home page Code Monkey logo

django_web's Introduction

xxx

license repo-size code-size

✨Features-持续更新

django3.x+vue3.x,CS系统,前后端分离,底层系统自定义构建的基础上和Vue_web进行接口联调,接口展示。同时运行两个项目可进行数据展示。 此版本的最终目的在于开发完成用户管理,数据可视化,算法/量化分析可视化等功能的前后端分离系统。 如有问题欢迎ISSUE

[🚓项目运行]uwsgi-asgi/wsgi

项目采用uwsgi工具可以启动,通信流程为:浏览器-http协议-nginx服务器-uwsgi协议-uwsgi服务器-uwsgi协议-python_wsgi_module_wsgi(python专用协议)-python_app(python应用)

  • 命令行启动

    • python manage.py runserver or python manage.py runserver 0.0.0.0:8000 --noreload
  • uwsgi启动

    • 安装虚拟环境,并设置好参数,注意修改下方参数中虚拟环境/项目文件目录是否正确
    • dev.ini 文件可直接启动并运行在后台
    • uwsgi.ini debug运行
  • [ ]pip install -r requirements.txt报错终端下载问题

    • 解决方法:编写shell脚本自动安装依赖;开发中...

开发完后再进行完善

😋Version_V2.1

前后端联调

数据基本由faker假数据生成

  • 预览
  • apps\dashboard: Vue_web仪表盘功能
    • kpi各个指标根据kpi_indicator接口工厂分配查询各指标,分多次请求查询各个kpi值
    • 仪表盘各类图标通过接口获取数据展示

apps-后端系统[需求文档]

先写文档再开发,先写注释再写代码

  • data

    • iris_data数据可视化接口:apps\data\views.py
  • data_analysis: 使用简单的numpy,pandas复现算法或者模型,并通过接口返回演示

    • Apriori算法实现:apps\data_analysis\models\apriori.py
    • FPgrowth算法实现:apps\data_analysis\moduls\FPgrowth\handler.py
    • SVM算法实现(预测):apps\data_analysis\moduls\svm\handler.py
    • 开发中...
  • models_sklearn_spark: 机器学习和各种模型算法小demo复现,并通过接口返回演示

    开发中...

  • models_tensorflow2: 使用tensorflow2复现论文,比赛等,并通过接口返回演示

    开发中...

  • utils: 网站系统功能

    • 创建网站数据类型,用于数据校验:apps\types.py
    • 结合wsme数据校验并扩展自定义数据结构,结合signature装饰器对接口的数据进行数据校验:apps\types.py
    • 自定义signature装饰器,应用于view模板,校验接口传参:apps\utils\wsme\signature.py
    • 自定义彩色日志系统,构建方法打印日志装饰器:apps\utils\log\handler.py
    • 继承rest framework框架的统一的异常处理:apps\utils\decorators\http.py
    • 重构django http请求方式校验,而不是再urls.py文件配置:apps\utils\decorators\http.py
      • 支持将用户指定url和request methods,并自动将url注册到apis连接下
      • 支持对request.user校验
      • 支持对jwt的token校验(jwt生成方式见jwt登陆验证)
        • 获得token校验后会更新token,将数据插入到返回的json中
  • jwt登陆验证

    • 将django-rest-framework-simplejwt中的CBV视图转换为FBV视图handlers:apps\accounts\handler.py

    • 使用jwt和session联合验证

      • 用户登陆创建后端session,设置有效时间,登出删除
      • 已登陆得用户删除登陆信息重新登陆
      • 用户修改用户基本信息
        • 用户修改密码
        • 其他-暂无此需求
    • 关闭django的csrftoken验证,开发简单的jwt登陆验证,绕过drf框架,直接使用django原生系统:apps\utils\jwt

    • 登陆接口化,继承rest framework框架登陆路由,扩展使用jwt原理扩展接口:apps\accounts\views.py

      https://django-rest-framework-simplejwt.readthedocs.io/en/latest/token_types.html#token-types; Simple JWT provides two different token types that can be used to prove authentication; 两种方式均可获得对应的token和user信息(user信息使用的序列化功能在

      • “access”, “sliding”:apps\accounts\views.py:token_obtain_pair()/token_access_refresh()
      • “refresh”:apps\accounts\views.py:token_obtain_sliding_login()/token_refresh()
    • vue 界面请求接口每次请求两次,一次为设定好的方式,第二次为option

      • 出现原因:
      • 解决方法:
    • 通过用户信息获取所属角色的界面权限并返回/前端根据返回权限进行渲染

  • apis

    • 获得所有urls:apps\apis\views.py

ele_admin 后端扩展功能

结合前端界面Vue_web进行开发调试

  • ele_admin\ele_admin_dashboard管理界面仪表盘界面

    数据由python的faker包生成,具体逻辑看代码

    • 前端查询展示的kpi 指标
    • kpi值接口 根据 indicator 传入参数不同请求不同的 handler
      • 查询系统总共用户数
    • 前端查询展示 dashboard/TransactionTable
    • 前端查询展示 dashboard/barChart
    • 前端查询展示 dashboard/BoxCard
    • 前端查询展示 dashboard/LineChart
    • 前端查询展示 dashboard/PieChart
    • 前端查询展示 dashboard/RaddarChart
    • 前端查询展示 dashboard/TodoList
  • ele_admin\ele_admin_interface接口(数据库操作)测试

  • recurrence_quantifucation_analysis:

    股票持仓量化分析 数据是现成的通过定期的爬取作展示

django+vue,CS系统,系统底层构建等。

网站采用传统的django MVT模式构建,使用bootstrap作为前端框架,用户管理、文章管理、评论系统、留言系统以及工具系统初步完善

🙃常见安装项目 bug

  • 都用django了为啥不用orm建?

    • 表结构修改/插入数据比较频繁,切插入的数据部分为后端自定义,建议使用navicat访问,手工插入/修改(或者写脚本)
  • 接口post请求莫名变成get请求:

    • 参考
    • pots请求在url定向的时候,如果末尾不是‘/’,会被系统重定向到带‘/’的url,即301,然后空的请求被重定向,就变成了get
    • 在url末尾加上/即可解决。
  • ImportError: PILKit was unable to import the Python Imaging Library. Please confirm it s installe...

    • 安装pillow库:pip install pillow
  • ModuleNotFoundError: No module named 'compressor'

    • 原因是安装django_compressor时的依赖包rcssm出了问题,重新安装rcssm包
    • pip install rcssmin --install-option="--without-c-extensions"
  • ImportError: cannot import name 'connections' from 'haystack'

    • 常见处理方法;写在自动安装的依赖包pip uninstall haystack,如果还不能解决,重新卸载并安装djang-haystack。
  • Linux系统django-haystack库安装失败

    • python比较好的地方就在于,出现异常抛出的异常上下文信息比较明确,能一眼看出问题所在,看了一下异常报错,原因在于当前虚拟环境下缺少setuptools_scm库,django-haystack的安装依赖这个库。python -m pip install setuptools_scm
  • ImportError: cannot import name 'ChineseAnalyzer' from 'jieba.analyse'

    • 安装依赖包whoosh,其实在requirement里面已经有了,但是估计时没安装成功吧。再安装一次就好了
  • ModuleNotFoundError: No module named 'user_agent'

    • 这个包直接安装就好, pip install user_agent
  • 数据库迁移/项目运行bug:ValueError : unsupported pickle protocol: 5

    • 这个bug根据pick协议,我们的查询功能whoosh功能时当我们访问这个页面,就将信息缓存下来,由于服务器py版本和win版本不一样可能会导致这个问题,解决方法就是删除项目中apps\search\whoosh_index文件夹中的所有文件。

关于作者

  • StrayCamel247:
    • C/S-WEB系统从大二就开始学习做,从express到djangp/flask都会一点,2020年第一次入职工作就是用flask开发的系统,通过此项目可以作为个人能力的一个展示。
    • 此项目会扩展成很多不同的demo,从市场经济股票基金到机器学习算法数据分析都会包含,立足于兴趣点并扩展本身的能力和知识点。

django_web's People

Contributors

dependabot[bot] avatar straycamel247 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

django_web's Issues

hi

什么时候更新learnku文章

登录502

你好,请问如何登录预览网站呢,使用默认用户名和密码显示502

Cannot login?

Hi, I am really interested in your project and want to run it. However, I cannot log in because I do not have the database information. Will you provide the detailed structure of the created tables?

观摩网站发现的一些问题

首先,你的文章内容,写的不错。

你的settings.py文件得设置DEBUG=False;
Snipaste_2019-11-14_14-52-26

自定义的get_tools标签一些没有在模版注册
Snipaste_2019-11-14_14-52-26

貌似还是个半成品。

愿天堂没有代码,哈哈。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.