码迷,mamicode.com
首页 > 其他好文 > 详细

xadmin下设置“use_bootswatch = True”无效解决方法

时间:2018-01-11 22:26:35      阅读:953      评论:0      收藏:0      [点我收藏+]

标签:set   div   user   图片   view   object   bubuko   gpo   httplib2   

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”无效解决方法

标签:set   div   user   图片   view   object   bubuko   gpo   httplib2   

原文地址:https://www.cnblogs.com/love1226/p/8270317.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!