![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Django
Django
1eeMamas
为追逐前人的步伐,走着走着,只剩下独自孤独的背影!
展开
-
Strak组件,关键字搜索
1.stark.pyfrom django.db.models import Qclass StarkAdmin(object): search_list=[] def get_search_list(self): val=[] val.extend(self.search_list) return val de...原创 2020-04-28 12:31:15 · 249 阅读 · 0 评论 -
Stark组件-批量操作实现
1.stark.pyclass StarkAdmin(object): def multi_delete(self,request): print('all delete') pk_list=request.POST.getlist('pk') self.model_class.objects.filter(pk__in=pk_...原创 2020-04-28 10:22:00 · 400 阅读 · 0 评论 -
Stark组件各种自定义功能~~
1获取列表的数据2.排序3.自定义字段class StarkAdmin(object): #排序 order_by = [] #显示列表字段 list_display=[] def __init__(self, model_class, site): self.model_class = model_class ...原创 2020-04-28 06:47:34 · 354 阅读 · 0 评论 -
django2 stark组件简单实现根据model创建url
1.创建app(stark)apps.pyfrom django.apps import AppConfigfrom django.utils.module_loading import autodiscover_modulesclass StarkConfig(AppConfig): name = 'stark' def ready(self): ...原创 2020-04-24 00:46:22 · 197 阅读 · 0 评论 -
django2 简单实现根据model创建url
1.创建models.pyfrom django.db import modelsclass Article(models.Model): title=models.CharField(max_length=32)2.urls.pyfrom django.contrib import adminfrom django.urls import path,includ...原创 2020-04-21 22:16:03 · 285 阅读 · 0 评论 -
原生form简单实现CURD
1.pycharm创建django项目2.app下models.pyfrom django.db import modelsclass Book(models.Model): title = models.CharField(max_length=32) price = models.DecimalField(max_digits=8, decimal_places...原创 2020-04-20 19:08:21 · 232 阅读 · 0 评论 -
Django权限管理rbac基于中间件校验简单实现
1.pycharm创建django项目2.app下models.pyfrom django.db import models#用户class User(models.Model): name = models.CharField(max_length=32) pwd = models.CharField(max_length=32) roles = mode...原创 2020-04-18 23:43:09 · 443 阅读 · 0 评论 -
Django结合Form组件实现curd功能
urls.pyfrom django.contrib import adminfrom django.urls import pathfrom app import viewsurlpatterns = [ path('admin/', admin.site.urls), path('class_list/',views.class_list ), pa...原创 2020-03-22 22:40:11 · 192 阅读 · 0 评论 -
Django Form和Ajax提交验证
Form验证views.pyclass LoginForm(Form): usr=fields.CharField(required=True,min_length=5, error_messages={ 'required':'不能为空', ...原创 2020-03-21 00:42:32 · 164 阅读 · 0 评论 -
Django中间件简单介绍
配置文件添加自定义mid.pyfrom django.utils.deprecation import MiddlewareMixinclass Mid(MiddlewareMixin): def process_request(self, request): print('start') def process_response(self,...原创 2020-03-14 19:56:13 · 97 阅读 · 0 评论 -
Django分页操作-内置和自定义分页使用
自定义分页最终效果:page.html<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>自定义分页</title></head><body> <ul> ...原创 2020-03-06 18:40:47 · 494 阅读 · 0 评论 -
Django视图ORM连表操作
正向:根据外键名访问链接的表反向:通过小写表名_set.all()取的def index(request): from app import models #连表(正向操作) list1=models.UserInfo.objects.all() for user in list1: print(user.id,user.pwd,use...原创 2020-03-06 04:30:57 · 162 阅读 · 0 评论 -
Django视图FBV与CBV
FBVfunction base views 就是在视图里使用函数处理请求。from django.http import HttpResponse def login(request): if request.method == 'GET': return HttpResponse('OK') else: return Http...原创 2020-03-06 04:22:56 · 144 阅读 · 0 评论 -
Django ORM创建与简单应用CRUD
创建ORMDjango默认使用SQLite数据库,要操作mysql,要利用pymysql1.要创建数据库2.配置settings.pyDATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':'xxxxx', 'USER': 'root', 'PASSWO...原创 2020-03-06 02:39:47 · 198 阅读 · 0 评论 -
Django路由系统
普通的url-->函数urls.py:from django.contrib import adminfrom django.http import HttpResponsefrom django.urls import pathdef index(request): return HttpResponse('index')urlpatterns = [ ...原创 2020-03-05 23:32:13 · 149 阅读 · 0 评论 -
pymysql简单封装
import pymysqlclass SqlHelper(object): def __init__(self): self.connect() def connect(self): self.conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd=...原创 2020-03-05 12:00:36 · 170 阅读 · 0 评论 -
模态对话框和Ajax的简单应用
模态对话框,适应少量输入框,简单数据处理,example:登录窗口新url:大量数据,大量操作Form表单提交,页面会刷新Ajax提交,页面不刷新js实现页面跳转location.href="url"<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"&...原创 2020-03-02 17:00:35 · 174 阅读 · 0 评论 -
Django简单CURD操作
url.py文件(路由分配url)from django.contrib import adminfrom django.urls import pathfrom app import viewsurlpatterns = [ path('classes/',views.classes), path('add_class/',views.add_class),...原创 2020-03-02 02:34:06 · 394 阅读 · 0 评论 -
Django简单认识配置和应用
命令行下创建pip install django命令d:/django-admin startproject mysite切换到目录下d:/mysiteD:\mysite>python manage.py runserver 127.0.0.1:4444 pycharm: 目录结构 Myweb -settings.py #配置文件 ...原创 2020-03-02 00:16:21 · 344 阅读 · 0 评论 -
PythonWeb框架本质
Web应用其实就是一个Socket服务端,用户浏览器就是Socket客户端实现简单的访问import socketsock = socket.socket()sock.bind(('127.0.0.1', 1234))sock.listen(5)while True: conn, addr = sock.accept() data = conn.recv(80...原创 2020-03-01 20:37:05 · 242 阅读 · 1 评论