Skip to main content

django soho ui base

Project description

django admin ui

1、在INSTALLED_APPS中添加django_sohoui

INSTALLED_APPS = [
    'django_sohoui',
    'django.contrib.admin',
    ....
]

2、克隆静态资源到项目的静态目录

python manage.py collectstatic

3、执行makemigrations

python manage.py makemigrations
python manage.py migrate      

4、在TEMPLATES中添加context_processor

'context_processors': [
    'django.template.context_processors.debug',
    'django.template.context_processors.request',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',
    ## 添加custom_context
    'django_sohoui.context_processors.custom_context',
]

5、在project/urls.py中添加django_sohoui

from django_sohoui.adminsite import adminsite
urlpatterns = [
    ## 添加django_sohoui
    path('admin/', adminsite.urls),
    path('django_sohoui/', include('django_sohoui.urls')),
]

6、 在project/settings.py中添加LOGIN_BG_IMAGE(自定义登录页背景图片)

SOHO_LOGIN_BG_IMAGE = '/static/custom/images/logo_bg.jpg'

7、 在project/settings.py中添加SOHO_MENU_LIST

SOHO_MENU_LIST = {
    'show_system_menu': True,
    'models':[
        {
            'name': '自定义页面',
            'models':[
                {
                    'name': '自定义页面',
                    'admin_url': '/django_sohoui/custom_url/'
                }
            ],
        }
    ]
}

X_FRAME_OPTIONS = 'SAMEORIGIN'

# 配置首页路由地址
LOGIN_REDIRECT_URL = '/django_sohoui/home/'

8、组件

统一引入:from django_sohoui.fields import * 效果:查看预览中adminform

输入框

类型:继承models.CharFiled 使用:UiCharField 案例:title = UiCharField(max_length=200, default='', verbose_name='标题')

文本框

类型:继承models.CharField 使用:UiTextField 案例:description = UiTextField(default='', null=True, blank=True, verbose_name='描述')

计数器

类型:继承models.IntegerField 使用:UiIntegerField 案例:count = UiIntegerField(default=0, verbose_name='计数')

浮点数

类型:继承models.FloatField 使用:UiFloatField 案例:price = UiFloatField(default=0.0, verbose_name='价格')

开关

类型:继承models.BooleanField 使用:UiSwitchField 案例:is_active = UiSwitchField(default=True, verbose_name='是否激活')

日期筛选器

类型:继承models.DateField 使用:UiDateField 案例:birth_date = UiDateField(null=True, blank=True, verbose_name='出生日期')

时间筛选器

类型:继承models.TimeField 使用:UiTimeField 案例:start_time = UiTimeField(null=True, blank=True, verbose_name='开始时间')

日期和时间

类型:继承models.DateTimeField 使用:UiDateTimeField 案例:created = UiDateTimeField(null=True, blank=True, verbose_name='创建时间')

邮箱

类型:继承models.EmailField 使用:UiEmailField 案例:email = UiEmailField(default='', null=True, blank=True, verbose_name='电子邮件')

url连接

类型:继承models.URLField 使用:UiURLField 案例:website = UiURLField(default='', null=True, blank=True, verbose_name='网站')

图片

类型:继承models.TextField 使用:UiImageCharField 案例:image = UiImageCharField(max_length=200, default='', null=True, blank=True, verbose_name='图片')

外建

类型:继承models.fields.related.ForeignKey 使用:UiForeignKeyField 案例:adminmenus = UiForeignKeyField(AdminMenus, on_delete=models.CASCADE, null=True, blank=True, verbose_name='菜单')

9、预览

登录页

index

adminlist

adminform

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_sohoui-1.3.9.tar.gz (7.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_sohoui-1.3.9-py3-none-any.whl (7.2 MB view details)

Uploaded Python 3

File details

Details for the file django_sohoui-1.3.9.tar.gz.

File metadata

  • Download URL: django_sohoui-1.3.9.tar.gz
  • Upload date:
  • Size: 7.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for django_sohoui-1.3.9.tar.gz
Algorithm Hash digest
SHA256 d1d04465e2a10231f0e46779905396b793036b1f2665deacbbde8fd7159beab8
MD5 7fc2bf7ecb3c09d8dfd0be26f8887700
BLAKE2b-256 8e093ffdbc1edfe6dbb10f03e1f87021b9450496e1f0354642707ac538459e82

See more details on using hashes here.

File details

Details for the file django_sohoui-1.3.9-py3-none-any.whl.

File metadata

  • Download URL: django_sohoui-1.3.9-py3-none-any.whl
  • Upload date:
  • Size: 7.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for django_sohoui-1.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b4797fcff7428fefcb26382d3e4e3f7fc81d7863820e940c623ba9ab54455d56
MD5 6f904bb05b0d3e9fef3f8fd919e88fa1
BLAKE2b-256 176d31ce7321986af283a55953ff9614e53324c5ee73bf3372435c034adcc2db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page