xadmin

github上搜索xadmin

安装

Xadmin is best installed via PyPI. To install the latest version, run:

pip install xadmin

or Install from github source:

pip install git+git://github.com/sshwsfc/xadmin.git

Install from github source for Django 2.0:

pip install git+git://github.com/sshwsfc/xadmin.git@django2

必须安装

  • django >=1.9

  • django-crispy-forms >=1.6.0 (For xadmin crispy forms)

  • django-reversion ([OPTION] For object history and reversion feature, please select right version by your django, see changelog )

  • django-formtools ([OPTION] For wizward form)

  • xlwt ([OPTION] For export xls files)

  • xlsxwriter ([OPTION] For export xlsx files)

  • django-import-export>=0.5.1

  • future==0.15.2

  • httplib2==0.9.2

  • six==1.10.0

配置

#settings.py
INSTALLED_APPS = (
    ...

    'xadmin',
    'crispy_forms',
    'reversion',

    ...
)
#url.py
import xadmin

urlpatterns = [
    path('xadmin/', xadmin.site.urls),
]
#xadmin.py 与 admin.py同目录
import xadmin
from .models import Goods, GoodsCategory


class GoodsAdmin(object):
    list_display = ["name", "price", "add_time"]
    search_fields = ['name', ]
    #list_editable = ["is_hot", ]
    list_filter = ["name", "price", "add_time", "category__name"]


class GoodsCategoryAdmin(object):
    list_display = ["name", "type", "parent_category", "add_time"]
    list_filter = ["type", "parent_category", "name"]
    search_fields = ['name', ]


xadmin.site.register(Goods, GoodsAdmin)
xadmin.site.register(GoodsCategory, GoodsCategoryAdmin)

你可能感兴趣的:(xadmin)