随笔分类 -  Python

摘要:Django时间时区 datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),得到的是标准时区的时间字符串 https://blog.csdn.net/qiaominghe/article/details/86593744 https://blog 阅读全文
posted @ 2024-02-13 16:18 Bruce_JRZ 阅读(15) 评论(0) 推荐(0)
摘要:1、动态Form form_handle.py from django.forms import ModelForm def create_dynamic_model_form(admin_class,form_add=False): """动态的生成modelform form_add: Fals 阅读全文
posted @ 2024-02-13 00:03 Bruce_JRZ 阅读(33) 评论(0) 推荐(0)
摘要:_meta.fields _meta.get_fields('字段名') _meta.fields_map _meta.many_to_many _meta.related_objects 待补充 dir() id() obj.get_internal_type() 阅读全文
posted @ 2024-02-12 23:58 Bruce_JRZ 阅读(14) 评论(0) 推荐(0)
摘要:Django提供了Admin来做后台管理 这里Kingadmin为自己做的后台管理 1、Kingadmin Base from django.shortcuts import render class BaseKingAdmin(object): list_display = [] list_fil 阅读全文
posted @ 2024-02-12 23:57 Bruce_JRZ 阅读(24) 评论(0) 推荐(0)
摘要:role base access control 基于角色的权限控制 1、Models from django.db import models class User(models.Model): name = models.CharField(max_length=32) password = m 阅读全文
posted @ 2024-02-12 23:41 Bruce_JRZ 阅读(63) 评论(0) 推荐(0)
摘要:XSSFilter.py from bs4 import BeautifulSoup class XSSFilter(object): __instance = None def __init__(self): # XSS白名单 self.valid_tags = { "font": ['color 阅读全文
posted @ 2024-02-12 23:09 Bruce_JRZ 阅读(18) 评论(0) 推荐(0)
摘要:check_code.py(需要字体文件:Monaco.ttf) import random from PIL import Image, ImageDraw, ImageFont, ImageFilter _letter_cases = "abcdefghjkmnpqrstuvwxy" # 小写字 阅读全文
posted @ 2024-02-12 18:16 Bruce_JRZ 阅读(38) 评论(0) 推荐(0)
摘要:def login(request): if request.method == 'GET': form = account.LoginForm() return render(request, 'login.html',{'form':form }) else: form = account.Lo 阅读全文
posted @ 2024-02-12 17:38 Bruce_JRZ 阅读(10) 评论(0) 推荐(0)