以下内容为原创,转载请注明出处!
一:安装xadmin:pip install django-xadmin,依赖于django-reversion
二:在setting.py里面的app中加入'xadmin','crispy_forms','reversion'
三:配置xadmin,在urls.py中加入,可以去掉原先的admin:
import xadmin xadmin.autodiscover()
四:url配置,同理可以去掉原先的admin:
url(r'^xadmin/', include(xadmin.site.urls), name='xadmin')
五:替换admin,注册需要替换为xadmin.site.register(model_name),有关封装需要查看文档;
六:进入django-xadmin后台之后,导出功能会出现BUG:
TypeError: __init__() got an unexpected keyword argument 'mimetype'
修改:xadmin/plugins/export.py中的218行:
response = HttpResponse( mimetype="%s; charset=UTF-8" % self.export_mimes[file_type])
改为:
response = HttpResponse()