DYBOY's Blog

Django集成Xadmin

将Github上的xadmin集成到项目中,方便自定义

xadmin+django

1.卸载原有安装的xadmin,但是保留扩展组建

python -m pip uninstall xadmin

2.安装扩展:

python -m pip install future six httplib2
python -m pip install django_import_export

3.打包xadmin

最新xadmin下载地址:https://github.com/sshwsfc/xadmin

将在github上下载的压缩包中的xadmin目录复制到项目中,在项目中新建一个python包(extra_apps),并marksource root,并将xadmin文件夹移动到extra_apps

4.更改路由:

settings.py 中:

import os
import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))

···
# 设置属性
LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False

urls.py

from django.conf.urls import url
import xadmin
from . import views

urlpatterns = [
    url(r'^xadmin/', xadmin.site.urls),
    url('', views.index, name="index"),
]

3.迁移:

python manage.py makemigrations
python manage.py migrate

4.运行:

python manage.py runserver
版权声明:《 Django集成Xadmin 》为DYBOY原创文章未经允许不得转载。

 DYBOY
 作者签名:安全从业者,爱好安全产品开发,渗透测试,Web漏洞研究

发表评论:

用心评论~

TOP
Powered by Emlog | Theme:Monkey by DYBOY
渝ICP备16008772号
sitemap