Django-Xadmin記錄

1 下載源碼:https://github.com/sshwsfc/xadminpython

2 加入工程文件git

3 pip install -r > requestments.txtgithub

django>=2
django-crispy-forms>=1.6.0
django-import-export>=0.5.1
django-reversion>=2.0.0
django-formtools==2.1
future==0.15.2
httplib2==0.9.2
six==1.10.0

 

4 Setting文件安裝django

INSTALLED_APPS = [
    'xadmin',
    'crispy_forms',
]

 5 ModuleNotFoundError: No module named 'xadmin' setting加入路徑
app

 

BASE_DIR=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0,os.path.join(BASE_DIR,'extra_apps'))
sys.path.insert(1,os.path.join(BASE_DIR,'apps'))

 

 6 ModuleNotFoundError: No module named 'django.contrib.formtools':將版本改爲django-formtools==2.1ssh

 7 建立數據模型後新建adminx.py註冊:分別爲顯示、搜索、過濾、圖標url

  

from message.models import Msg
from xadmin.sites import site

class MsgAdmin(object):
    list_display = ['name','msg_content','msg_email','msg_time']
    search_fileds = ['name','msg_content','msg_email','msg_time']
    list_filter = ['name','msg_content','msg_email','msg_time','msg_sex']
    model_icon = 'fa fa-book fa-fw'

site.register(Msg,MsgAdmin)

 8 建立adminx.pyspa

from xadmin import views
from job.models import job51
from xadmin.sites import site
# Register your models here.

class Job51Admin(object):
    refresh_times = [10,20,50]
    search_fields =('date','jobaddress')
    list_display = ('job','company','jobaddress','date','wages','joburl')
    model_icon = 'fa fa-home fa-fw'
    ordering = ['-date']
site.register(job51,Job51Admin)


#添加主題功能
class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True
site.register(views.BaseAdminView, BaseSetting)


#修改頭文件及腳本顯示
class GlobalSetting(object):
    site_title = "喻曉生後臺管理系統"
    site_footer = "http://daydayup11.cn"
    menu_style = "accordion"
site.register(views.CommAdminView, GlobalSetting)

 9 django.urls.exceptions.NoReverseMatch: Reverse for 'xadmin_userwidget_add' with no argumen:報錯緣由adminx/後面不能加$3d

10 python manage.py createsuperuser建立用戶、migrations、migrateorm

11   http://192.168.2.246:8000/xadmin/訪問

相關文章
相關標籤/搜索