随笔分类 -  django

摘要:Template filters that expect strings¶ django.template.defaultfilters.stringfilter()¶ 如果你正在编写一个只希望用一个字符串来作为第一个参数的模板过滤器,你应当使用stringfilter装饰器。 这将在对象被传入你的 阅读全文
posted @ 2020-09-30 11:51 Fmaj-7 阅读(413) 评论(0) 推荐(0)
摘要:转:https://blog.csdn.net/weixin_39726347/article/details/88036299 阅读全文
posted @ 2020-09-29 17:13 Fmaj-7 阅读(364) 评论(0) 推荐(0)
摘要:is_safe_url() 对其进行验证。文档字符串很好地解释了它的用法: is_safe_url(url, host=None, allowed_hosts=None, require_https=False) 如果url是安全重定向(即不会指向其他主机并使用安全方案),则返回True。空 url 阅读全文
posted @ 2020-09-29 16:16 Fmaj-7 阅读(559) 评论(0) 推荐(0)
摘要:过滤敏感信息¶ 错误报告对于调试错误确实很有帮助,因此通常记录尽可能多的有关这些错误的相关信息非常有用。例如,默认情况下,Django会记录引发的异常的完整追溯,每个追溯框架的局部变量以及 HttpRequest的属性。 但是,有时某些类型的信息可能过于敏感,因此可能不适用于跟踪例如用户的密码或信用 阅读全文
posted @ 2020-09-29 12:00 Fmaj-7 阅读(342) 评论(0) 推荐(0)
摘要:pip install setuptools-scm 转自:https://www.cnblogs.com/ruhai/p/11166876.html 阅读全文
posted @ 2020-08-17 16:03 Fmaj-7 阅读(90) 评论(0) 推荐(0)
摘要:1 def populate(self, installed_apps=None): 2 """ 3 Loads application configurations and models. 4 5 This method imports each application module and th 阅读全文
posted @ 2020-08-17 10:10 Fmaj-7 阅读(150) 评论(0) 推荐(0)
摘要:1 class ModelFormUploadFile(models.Model): 2 '''ModelForm测试上传文件''' 3 name = models.FileField(upload_to=settings.MEDIA_ROOT) 4 5 class Meta: 6 db_table 阅读全文
posted @ 2020-08-11 17:06 Fmaj-7 阅读(571) 评论(0) 推荐(0)
摘要:1 mixin.py 2 from django.contrib.auth.decorators import login_required 3 4 class LoginRequireMixin(object): 5 '''登录装饰''' 6 @classmethod 7 def as_view( 阅读全文
posted @ 2020-08-07 09:23 Fmaj-7 阅读(151) 评论(0) 推荐(0)
摘要:settings.py 1 CACHES = { 2 "default": { 3 "BACKEND": "django_redis.cache.RedisCache", 4 "LOCATION": "redis://192.168.10.129:6379/0", 5 "OPTIONS": { 6 阅读全文
posted @ 2020-08-05 22:22 Fmaj-7 阅读(154) 评论(0) 推荐(0)
摘要:1 TINYMCE_DEFAULT_CONFIG = { 2 # // General options 3 'mode': 'textareas', 4 'theme': "advanced", 5 'plugins': "pagebreak,style,layer,table,save,advhr 阅读全文
posted @ 2020-08-05 14:04 Fmaj-7 阅读(392) 评论(0) 推荐(0)
摘要:1 from django.contrib.auth.backends import ModelBackend 2 from django.contrib.auth import get_user_model 3 from django.db.models import Q 4 5 UserMode 阅读全文
posted @ 2020-08-04 10:48 Fmaj-7 阅读(230) 评论(0) 推荐(0)
摘要:1 class ModelBackend(object): 2 """ 3 Authenticates against settings.AUTH_USER_MODEL. 4 """ 5 6 def authenticate(self, request, username=None, passwor 阅读全文
posted @ 2020-08-04 10:41 Fmaj-7 阅读(122) 评论(0) 推荐(0)
摘要:当使用:python manage.py runserver 0.0.0.0:8080方法启动开发服务器时,如果对python代码进行修改,则服务器会自动重启。 当使用:python manage.py runserver 0.0.0.0:8080 --noreload方法启动开发服务器时,对dja 阅读全文
posted @ 2020-07-14 10:15 Fmaj-7 阅读(914) 评论(0) 推荐(0)
摘要:class _AttributeHolder(object): """Abstract base class that provides __repr__. The __repr__ method returns a string in the format:: ClassName(attr=nam 阅读全文
posted @ 2020-07-14 09:55 Fmaj-7 阅读(229) 评论(0) 推荐(0)
摘要:dict(kwargs, dest=dest, option_strings=[]) 请思考输出结果? 阅读全文
posted @ 2020-07-08 15:45 Fmaj-7 阅读(127) 评论(0) 推荐(0)
摘要:class _ActionsContainer(object): def __init__(self): self._registries = {} def register(self, registry_name, value, object): registry = self._registri 阅读全文
posted @ 2020-07-08 14:42 Fmaj-7 阅读(230) 评论(0) 推荐(0)
摘要:1 # @Time : ${DATE} ${HOUR}:${MINUTE} 2 # @Author : xxx 3 # @Email : 1371063xxx@139.com 4 # @File : ${NAME}.py 5 # @Software: ${PRODUCT_NAME} # @Time 阅读全文
posted @ 2020-07-01 10:45 Fmaj-7 阅读(251) 评论(0) 推荐(0)
摘要:1 def _parse_known_args(self, arg_strings, namespace): 2 # replace arg strings that are file references 3 if self.fromfile_prefix_chars is not None: 4 阅读全文
posted @ 2020-06-24 11:49 Fmaj-7 阅读(213) 评论(0) 推荐(0)
摘要:1 def load_command_class(app_name, name): 2 """ 3 Given a command name and an application name, returns the Command 4 class instance. All errors raise 阅读全文
posted @ 2020-06-24 09:59 Fmaj-7 阅读(323) 评论(0) 推荐(0)
摘要:Python callable() 函数 Python 内置函数 描述 callable() 函数用于检查一个对象是否是可调用的。如果返回 True,object 仍然可能调用失败;但如果返回 False,调用对象 object 绝对不会成功。 对于函数、方法、lambda 函式、 类以及实现了 _ 阅读全文
posted @ 2020-06-23 11:54 Fmaj-7 阅读(206) 评论(0) 推荐(0)