发送ajax: $.ajax({ url: "xxx", type: "GET", data: {}, dataType: "JSON", success: function(res) {}, }) 参数详解url: url:"/xx/xx/" && "{% url 'Login' %}" 参数详解 Read More
posted @ 2022-07-27 11:56 角角边 Views(506) Comments(0) Diggs(0)
class封装返回值 常见的我们返回值都是{"xx": "xx", },其实我们可以优化返回值,通过class封装。 from django.http import JsonResponse class Response(object): def __init__(self): self.statu Read More
posted @ 2022-07-26 17:58 角角边 Views(43) Comments(0) Diggs(0)
前后端不分离模式,如何取到csrftoken 方式1: 导入一下js文件: // 根据cookie的name获取对应的值 function getCookie(name) { let cookieValue = null; if (document.cookie && document.cookie Read More
posted @ 2022-07-26 15:44 角角边 Views(87) Comments(0) Diggs(0)
1 项目结构 以下主要是以drf编写api时的结构为示例。 1.1 APP结构 1.1.1 单APP 例如:订单系统 1.1.2 Base + 业务APP 例如:供应链系统 1.1.3 独立的APP app中的功能各自独立的,每个app中编写自己的 models / views 等。 1.2 视图结 Read More
posted @ 2023-01-25 17:05 角角边 Views(88) Comments(0) Diggs(0)
视图 from django.shortcuts import render from django.db.models import Q from utils.pager import Pagination from web import models def transaction_list(r Read More
posted @ 2022-10-14 15:10 角角边 Views(50) Comments(0) Diggs(0)
ModelForm自定义字段的显示效果 class ChargeModelForm(BootStrapModelForm, forms.ModelForm): # 静态变量 # charge_type = forms.ChoiceField( # label='类型', # choices=[(1, Read More
posted @ 2022-10-12 16:53 角角边 Views(69) Comments(0) Diggs(0)
基于bootstrap V3 应用 pager.py: """ 如果想要使用分页,需要以下两个步骤 def xxx(): queryset = models.TransactionRecord.objects.filter(customer_id=pk, customer__active=1).or Read More
posted @ 2022-10-10 16:54 角角边 Views(61) Comments(0) Diggs(0)
在相应的app文件夹中,创建templatetags文件夹,必须是templatetags文件夹命名: 注意:templatetags文件夹中必须要有__init__.py文件 jd.py: from django import template register = template.Librar Read More
posted @ 2022-10-08 14:36 角角边 Views(44) Comments(0) Diggs(0)
常用与ajax数据返回: class BaseResponse(object): def __init__(self, status=False, detail=None, data=None): self.status = status self.detail = detail self.data Read More
posted @ 2022-10-05 10:29 角角边 Views(47) Comments(0) Diggs(0)
在模板中引用响应的文件 比如: layout.html <link rel="stylesheet" href="{% static 'stark/plugins/datetimepicker/css/bootstrap-datetimepicker.css' %} "/> <script src= Read More
posted @ 2022-09-28 17:33 角角边 Views(126) Comments(0) Diggs(0)
腾讯云短信服务,来进行发送短信。 注册账号 开通服务 + 缴费 (实名、企业认证,公众号) API服务、SDK服务 API,接口 import requests # 在此之前还会处理签名和加密的工作量 res = requests.get("......",params={"key":"xxx",' Read More
posted @ 2022-09-28 17:07 角角边 Views(69) Comments(0) Diggs(0)
方式1: mtb/scripts/create_user.py # 离线脚本(添加数据) import os, sys, django base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.ap Read More
posted @ 2022-09-28 15:44 角角边 Views(52) Comments(0) Diggs(0)
Login.vue <template> <div class="main"> <div class="loginBox"> <div class="tabBoxSwitch"> <ul class="tabBoxSwitchUl"> <li :class="tabSelected index?'t Read More
posted @ 2022-09-27 16:57 角角边 Views(53) Comments(0) Diggs(0)
方式1: models.xx.objects.filter(Q(id=10)) models.xx.objects.filter(Q(id=10)&Q(age=10) # and models.xx.objects.filter(Q(id=10)|Q(age=10) # or models.xx.o Read More
posted @ 2022-09-14 16:04 角角边 Views(298) Comments(0) Diggs(0)
常用模块导入 1 forms # forms组件的使用 from django import forms 2 ValidationError # modelform报错时使用 from django.core.exceptions import ValidationError 3 mark_safe Read More
posted @ 2022-09-14 16:04 角角边 Views(241) Comments(0) Diggs(0)
import hashlib def gen_md5(origin): """md5加密""" ha = hashlib.md5(b'lkplkp123123') ha.update(origin.encode('utf-8')) return ha.hexdigest() Read More
posted @ 2022-09-14 15:29 角角边 Views(39) Comments(0) Diggs(0)
方便之处在于,我们不会再一遍一遍的写form的样式了。 from django import forms class BootStrapModelForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(BootStrapMo Read More
posted @ 2022-09-01 15:45 角角边 Views(137) Comments(0) Diggs(0)
简单来讲: 如果你想传入前端的页面中附带值,那么在实例化forms中: form = SecondModelForm(data=request.POST, instance=permission_obj) return render(request, 'rbac/change.html', {'fo Read More
posted @ 2022-09-01 15:25 角角边 Views(98) Comments(0) Diggs(0)
1 local_settings 第一步:需要在项目根目录下的settings配置如下 try: from .local_settings import * except Exception: pass 第二步:在项目目录下创建local_settings.py文件 2 .gitignore 可以在 Read More
posted @ 2022-08-30 10:00 角角边 Views(78) Comments(0) Diggs(0)
给用户进行权限的分配。 1 角色管理 项目目录下urls新增一条url from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.s Read More
posted @ 2022-08-29 17:47 角角边 Views(58) Comments(0) Diggs(0)