Django采坑日志(django2.0)
- 使用Mariadb时出现的问题
“Unknown system variable 'transaction_isolation‘”
解决办法:修改django/db/backends/mysql/base.py 文件大概240行左右如下部分(增添一个判断条件)
@cached_property def transaction_isolation_variable(self): return 'tx_isolation' if self.mysql_version < (5, 7, 20) or self.mysql_version > (10, 0, 10) else 'transaction_isolation'
- python manage.py startapp APPNAME 后一般要做的操作
编辑 setting.py
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'APPNAME.apps.APPNAMEConfig', ]
TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ]
html文件放在APPNAME/templates/下