随笔分类 -  django

摘要:1 class CommandParser(ArgumentParser): 2 """ 3 Customized ArgumentParser class to improve some error messages and prevent 4 SystemExit in several occa 阅读全文
posted @ 2020-06-23 09:11 Fmaj-7 阅读(171) 评论(0) 推荐(0)
摘要:Python any() 函数 Python 内置函数 描述 any() 函数用于判断给定的可迭代参数 iterable 是否全部为 False,则返回 False,如果有一个为 True,则返回 True。 元素除了是 0、空、FALSE 外都算 TRUE。 函数等价于: def any(iter 阅读全文
posted @ 2020-06-23 09:02 Fmaj-7 阅读(451) 评论(0) 推荐(0)
摘要:1 dict1 = {'a': 1, 'b': 2, 'c': 3} 2 dict1.update({'d': 4, 'e': 5, 'c': 100}) 3 dict1.update({'c': 100}) #不会删除,只会增加或修改 4 print(dict1) 1 dict2 = {} 2 d 阅读全文
posted @ 2020-06-22 11:10 Fmaj-7 阅读(230) 评论(0) 推荐(0)
摘要:1 def find_commands(management_dir): 2 """ 3 Given a path to a management directory, returns a list of all the command 4 names that are available. 5 6 阅读全文
posted @ 2020-06-22 09:53 Fmaj-7 阅读(254) 评论(0) 推荐(0)
摘要:Python map() 函数 Python 内置函数 描述 map() 会根据提供的函数对指定序列做映射。 第一个参数 function 以参数序列中的每一个元素调用 function 函数,返回包含每次 function 函数返回值的新列表。 语法 map() 函数语法: map(functio 阅读全文
posted @ 2020-06-21 15:26 Fmaj-7 阅读(172) 评论(0) 推荐(0)
摘要:import random def yield_test(n): for i in range(n): yield call(i) print("i=",i) #做一些其它的事情 print("do something.") print("end.") def call(i): return i*2 阅读全文
posted @ 2020-06-21 11:19 Fmaj-7 阅读(194) 评论(0) 推荐(0)
摘要:def get_commands(): """ Returns a dictionary mapping command names to their callback applications. This works by looking for a management.commands pac 阅读全文
posted @ 2020-06-20 18:08 Fmaj-7 阅读(208) 评论(0) 推荐(0)
摘要:def __setattr__(self, name, value): """ Set the value of setting. Clear all cached values if _wrapped changes (@override_settings does this) or clear 阅读全文
posted @ 2020-06-20 09:54 Fmaj-7 阅读(895) 评论(0) 推荐(0)
摘要:counts = Counter( app_config.name for app_config in self.app_configs.values()) Counter({'django_celery_beat': 1, 'django.contrib.sessions': 1, 'corshe 阅读全文
posted @ 2020-06-19 16:26 Fmaj-7 阅读(141) 评论(0) 推荐(0)
摘要:Python issubclass() 函数 Python 内置函数 描述 issubclass() 方法用于判断参数 class 是否是类型参数 classinfo 的子类。 语法 以下是 issubclass() 方法的语法: issubclass(class, classinfo) 参数 cl 阅读全文
posted @ 2020-06-19 14:26 Fmaj-7 阅读(149) 评论(0) 推荐(0)
摘要:Python rpartition() 方法 Python 字符串 描述 rpartition() 方法类似于 partition() 方法,只是该方法是从目标字符串的末尾也就是右边开始搜索分割符。。 如果字符串包含指定的分隔符,则返回一个3元的元组,第一个为分隔符左边的子串,第二个为分隔符本身,第 阅读全文
posted @ 2020-06-19 14:21 Fmaj-7 阅读(302) 评论(0) 推荐(0)
摘要:当唔异常时,else方法也执行 try: # If import_module succeeds, entry is a path to an app module, # which may specify an app config class with default_app_config. # 阅读全文
posted @ 2020-06-19 14:16 Fmaj-7 阅读(426) 评论(0) 推荐(0)
摘要:FBV FBV(function base views) 就是在视图里使用函数处理请求。 CBV CBV(class base views) 就是在视图里使用类处理请求。 Python是一个面向对象的编程语言,如果只用函数来开发,有很多面向对象的优点就错失了(继承、封装、多态)。所以Django在后 阅读全文
posted @ 2020-06-18 09:32 Fmaj-7 阅读(553) 评论(0) 推荐(0)
摘要:import hashlib #1,首先引入hashlib模块 def password_encrypt(pwd): md5 = hashlib.md5() # 2,实例化md5() 方法 md5.update(pwd.encode()) # 3,对字符串的字节类型加密 ret = md5.hexd 阅读全文
posted @ 2020-06-16 10:59 Fmaj-7 阅读(286) 评论(0) 推荐(0)
摘要:from django.utils.functional import cached_property import datetime class User(object): birth_year = 1988 @cached_property def age(self): return datet 阅读全文
posted @ 2020-06-15 15:45 Fmaj-7 阅读(207) 评论(0) 推荐(0)
摘要:if installed_apps is None and hasattr(sys.modules[__name__], 'apps'): raise RuntimeError("You must supply an installed_apps argument.")print(sys.modul 阅读全文
posted @ 2020-06-15 14:32 Fmaj-7 阅读(423) 评论(0) 推荐(0)
摘要:def __new__(mcs, name, bases, attrs): # Collect fields from current class. current_fields = [] for key, value in list(attrs.items()): if isinstance(va 阅读全文
posted @ 2020-06-13 10:29 Fmaj-7 阅读(181) 评论(0) 推荐(0)
摘要:class TestModel(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=200) test = models.ForeignKey('TestModel', 阅读全文
posted @ 2020-04-08 15:28 Fmaj-7 阅读(255) 评论(0) 推荐(0)
摘要:yum install gcc-c++ yum install python3-devel.x86_64 pip install uwsgi 阅读全文
posted @ 2020-02-21 15:52 Fmaj-7 阅读(378) 评论(0) 推荐(0)
摘要:views.py class AnalysisDataHandler(View): def get(self, request): analysis_data = MonitorCenterDataAnalysis.objects.all().order_by('create_time').reve 阅读全文
posted @ 2020-01-17 12:14 Fmaj-7 阅读(188) 评论(0) 推荐(0)