xadmin下设置“use_bootswatch = True”无效解决方法
Posted zwb21fang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xadmin下设置“use_bootswatch = True”无效解决方法相关的知识,希望对你有一定的参考价值。
from xadmin import views
import xadmin
class BaseSetting(object):
enable_themes=True
use_bootswatch=True
xadmin.site.register(views.BaseAdminView,BaseSetting)
复制一下代码到相应位置
try:
flag = False # 假如为True使用原来的代码,假如为Flase,使用requests库来访问
if flag:
h = httplib2.Http()
resp, content = h.request("http://bootswatch.com/api/3.json", \'GET\', \'\',
headers={"Accept": "application/json",
"User-Agent": self.request.META[\'HTTP_USER_AGENT\']})
if six.PY3:
content = content.decode()
watch_themes = json.loads(content)[\'themes\']
else:
content = requests.get("https://bootswatch.com/api/3.json")
if six.PY3:
content = content.text.decode()
watch_themes = json.loads(content.text)[\'themes\']
ex_themes.extend([
{\'name\': t[\'name\'], \'description\': t[\'description\'],
\'css\': t[\'cssMin\'], \'thumbnail\': t[\'thumbnail\']}
for t in watch_themes])
# h = httplib2.Http()
# resp, content = h.request("https://bootswatch.com/api/3.json", \'GET\', \'\',
# headers={"Accept": "application/json", "User-Agent": self.request.META[\'HTTP_USER_AGENT\']})
# if six.PY3:
# content = content.decode()
# watch_themes = json.loads(content)[\'themes\']
# ex_themes.extend([
# {\'name\': t[\'name\'], \'description\': t[\'description\'],
# \'css\': t[\'cssMin\'], \'thumbnail\': t[\'thumbnail\']}
# for t in watch_themes])
except Exception as e:
print(e)
以上是关于xadmin下设置“use_bootswatch = True”无效解决方法的主要内容,如果未能解决你的问题,请参考以下文章
xadmin下设置“use_bootswatch = True”无效解决方法