09 2022 档案

摘要:实现效果:除登录接口无需认证,其他接口如果从params或者头部AUTHORIZATION没有获取到token,则直接认证失败。如果去掉NoAuthentication,则支持匿名访问 认证类 from rest_framework.authentication import BaseAuthent 阅读全文
posted @ 2022-09-30 20:13 Sherwin_szw 阅读(24) 评论(0) 推荐(0) 编辑
摘要:认证类(不能写在视图里) rom rest_framework.authentication import BaseAuthentication from rest_framework.exceptions import AuthenticationFailed class MyAuthentica 阅读全文
posted @ 2022-09-30 14:34 Sherwin_szw 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2022-09-30 11:31 Sherwin_szw 阅读(11) 评论(0) 推荐(0) 编辑
摘要:路由 urlpatterns = [ path('order/', views.OrderView.as_view()), ] 视图关系 class View(object): @classonlymethod def as_view(cls, **initkwargs): def view(req 阅读全文
posted @ 2022-09-30 10:11 Sherwin_szw 阅读(15) 评论(0) 推荐(0) 编辑
摘要:因为python中所有类默认继承object类。而object类提供了了很多原始的内建属性和方法,所以用户自定义的类在Python中也会继承这些内建属性。可以使用dir()函数可以查看,虽然python提供了很多内建属性但实际开发中常用的不多。而很多系统提供的内建属性实际开发中用户都需要重写后才会使 阅读全文
posted @ 2022-09-29 20:31 Sherwin_szw 阅读(83) 评论(0) 推荐(0) 编辑
摘要:当我们访问一个不存在的属性的时候,会抛出异常,提示我们不存在这个属性。而这个异常就是__getattr__方法抛出的,其原因在于他是访问一个不存在的属性的最后落脚点,作为异常抛出的地方提示出错再适合不过了。 class A(object): def __init__(self, value): se 阅读全文
posted @ 2022-09-29 19:02 Sherwin_szw 阅读(22) 评论(0) 推荐(0) 编辑
摘要:报错 Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. 原因 阅读全文
posted @ 2022-09-29 17:38 Sherwin_szw 阅读(84) 评论(0) 推荐(0) 编辑
摘要:django的request对象 request.method request.GET request.POST request.body request.FILES drf中的request参数,又一层封装 request._request.GET request._request.POST re 阅读全文
posted @ 2022-09-29 16:13 Sherwin_szw 阅读(43) 评论(0) 推荐(0) 编辑
摘要:路由 urlpatterns = [ path('login/', views.LoginView.as_view()), path('login2/', views.login2), ] 视图 from django.views import View from django.http impor 阅读全文
posted @ 2022-09-29 11:39 Sherwin_szw 阅读(16) 评论(0) 推荐(0) 编辑
摘要:安装 pip install djangorestframework 注册 INSTALLED_APPS = [ "rest_framework", ] 配置路由 urlpatterns = [ path('auth/', views.auth), path('login2/', views.log 阅读全文
posted @ 2022-09-29 11:18 Sherwin_szw 阅读(39) 评论(0) 推荐(0) 编辑
摘要:reboot.sh #!/usr/bin/env bash echo -e "\033[34m wsgi process \033[0m" ps -ef|grep uwsgi_order_trading_platform.ini | grep -v grep sleep 0.5 echo -e '\ 阅读全文
posted @ 2022-09-27 19:10 Sherwin_szw 阅读(134) 评论(0) 推荐(0) 编辑
摘要:nginx.conf内 #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/n 阅读全文
posted @ 2022-09-27 17:00 Sherwin_szw 阅读(73) 评论(0) 推荐(0) 编辑
摘要:进入虚拟环境 source activate 安装uwsgi pip install uwsgi 命令运行 uwsgi --http :80 --chdir /usr/local/projects/order_trading_platform/ --wsgi-file order_trading_p 阅读全文
posted @ 2022-09-27 14:19 Sherwin_szw 阅读(54) 评论(0) 推荐(0) 编辑
摘要:安装 $ cd /usr/local/ $ sudo wget http://nginx.org/download/nginx-1.8.0.tar.gz $ sudo tar -zxvf nginx-1.8.0.tar.gz $ cd nginx-1.8.0 $ sudo ./configure - 阅读全文
posted @ 2022-09-27 13:58 Sherwin_szw 阅读(35) 评论(0) 推荐(0) 编辑
摘要:一键安装 cd /usr/local && yum install -y gcc tcl && wget https://github.com/redis/redis/archive/7.0.4.tar.gz && tar -zxvf /usr/local/7.0.4.tar.gz && cd /u 阅读全文
posted @ 2022-09-27 09:29 Sherwin_szw 阅读(263) 评论(0) 推荐(0) 编辑
摘要:第一步:下载 wget https://dev.mysql.com/get/mysql80-community-release-el8-3.noarch.rpm 第二步:安装 yum install mysql80-community-release-el8-3.noarch.rpm 命令关闭cen 阅读全文
posted @ 2022-09-27 08:10 Sherwin_szw 阅读(56) 评论(0) 推荐(0) 编辑
摘要:local_settings.py import os from pathlib import Path DEBUG = False ALLOWED_HOSTS = ['*'] BASE_BASE_DIR = Path(__file__).resolve().parent.parent.parent 阅读全文
posted @ 2022-09-25 19:38 Sherwin_szw 阅读(97) 评论(0) 推荐(0) 编辑
摘要:第一步:安装git客户端,默认安装在/usr/libexec/git-core目录 yum -y install git #查看版本 git --version 第二步:配置git信息 git config --global user.name "username" git config --glo 阅读全文
posted @ 2022-09-25 19:17 Sherwin_szw 阅读(266) 评论(0) 推荐(0) 编辑
摘要:创建envs目录 mkdir envs 创建虚拟环境 python -m venv django_env 启用虚拟环境 source activate 退出虚拟环境 deactivate 安装包 pip3 install -r requirements.txt 阅读全文
posted @ 2022-09-25 12:38 Sherwin_szw 阅读(26) 评论(0) 推荐(0) 编辑
摘要:升级openssl # 1. 查看当前openssl的版本信息 openssl version #1.0.2 需要升级 # 2. 安装对应的依赖库 sudo yum -y groupinstall "Development tools" sudo yum -y install zlib-devel 阅读全文
posted @ 2022-09-25 12:08 Sherwin_szw 阅读(733) 评论(0) 推荐(0) 编辑
摘要:settings内 。。。 try: from .local_settings import * except Exception as e: print(e) local_settings内 写本地/线上配置 。。。 阅读全文
posted @ 2022-09-25 09:51 Sherwin_szw 阅读(21) 评论(0) 推荐(0) 编辑
摘要:# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ 阅读全文
posted @ 2022-09-25 09:45 Sherwin_szw 阅读(644) 评论(0) 推荐(0) 编辑
摘要:构造 class Connect: def __init__(self): pass def __enter__(self): #链接数据库 return self def __exit__(self,exc_type,exc_val,exc_tb): #关闭数据库 pass def fetchon 阅读全文
posted @ 2022-09-25 08:25 Sherwin_szw 阅读(23) 评论(0) 推荐(0) 编辑
摘要:前端html {% if sg.get_row_list %} <div class="panel panel-default "> <div class="panel-heading"> <i class="fa fa-filter" aria-hidden="true"></i> 快速筛选 </ 阅读全文
posted @ 2022-09-24 14:24 Sherwin_szw 阅读(32) 评论(0) 推荐(0) 编辑
摘要:settings INSTALLED_APPS = [ 'django.contrib.messages', # 第一个位置 ] MIDDLEWARE = [ 'django.contrib.messages.middleware.MessageMiddleware', # 第二个位置 ] TEMP 阅读全文
posted @ 2022-09-23 10:05 Sherwin_szw 阅读(38) 评论(0) 推荐(0) 编辑
摘要:前端 {% extends 'layout.html' %} {% load static %} {% block content %} <div class="panel panel-default"> <!-- Default panel contents --> <div class="pan 阅读全文
posted @ 2022-09-19 17:10 Sherwin_szw 阅读(28) 评论(0) 推荐(0) 编辑
摘要:django 后端逻辑 def transaction_add(request, pk): res_code = ResCode() if request.method == 'POST': form = TransactionForm(data=request.POST) if not form. 阅读全文
posted @ 2022-09-17 18:27 Sherwin_szw 阅读(36) 评论(0) 推荐(0) 编辑
摘要:前端js <script> $(function () { $("#addBtn").click(function () { $("#addModal").modal('show') }) $("#submitBtn").click(function () { $.ajax({ url: "{% u 阅读全文
posted @ 2022-09-17 12:53 Sherwin_szw 阅读(28) 评论(0) 推荐(0) 编辑
摘要:model class TransactionRecord(ActiveBaseModel): status_class_mapping = { 1: 'info', 2: 'danger', 3: 'success', 4: 'primary', 5: 'warning', } choice_st 阅读全文
posted @ 2022-09-16 15:01 Sherwin_szw 阅读(57) 评论(0) 推荐(0) 编辑
摘要:前端按钮 {% edit_btn request 'user_edit' pk=user.id %} 后端逻辑 @register.simple_tag def edit_btn(request, url_name, *args, **kwargs): if not check_per(reques 阅读全文
posted @ 2022-09-15 20:02 Sherwin_szw 阅读(30) 评论(0) 推荐(0) 编辑
摘要:前端 {% load btnPermission %} {% add_btn request 'level_add' %} {% edit_btn request 'level_edit' pk=user_level.id %} {% delete_btn request 'level_delete 阅读全文
posted @ 2022-09-15 08:22 Sherwin_szw 阅读(34) 评论(0) 推荐(0) 编辑
摘要:模态框部分 <!-- Modal --> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog modal-s 阅读全文
posted @ 2022-09-14 07:43 Sherwin_szw 阅读(38) 评论(0) 推荐(0) 编辑
摘要:添加按钮 <div class="pull-left"><a href="{% url 'price_policy_add' %}" class="btn-success btn" style="margin-bottom: 10px"><i class="fa fa-plus-square-o"> 阅读全文
posted @ 2022-09-13 20:59 Sherwin_szw 阅读(27) 评论(0) 推荐(0) 编辑
摘要:前端 <table class="table table-hover table-bordered"> <tr> <th>序号</th> <th>数量</th> <th>价格</th> </tr> {% for one in queryset %} <tr user-id="{{ one.id }} 阅读全文
posted @ 2022-09-13 20:39 Sherwin_szw 阅读(40) 评论(0) 推荐(0) 编辑
摘要:前端 <nav aria-label="Page navigation"> <ul class="pagination"> {{ html_str }} </ul> </nav> 后端 分页组件 from django.utils.safestring import mark_safe import 阅读全文
posted @ 2022-09-13 17:12 Sherwin_szw 阅读(13) 评论(0) 推荐(0) 编辑
摘要:后端 from django.db.models import Q def user_list(request): if request.method == 'GET': keywords = request.GET.get('keywords').strip() con = Q() if keyw 阅读全文
posted @ 2022-09-13 16:12 Sherwin_szw 编辑

点击右上角即可分享
微信分享提示
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.