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.8.tar.gz (6.9 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.8-py3-none-any.whl (6.9 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_sohoui-1.3.8.tar.gz
  • Upload date:
  • Size: 6.9 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.8.tar.gz
Algorithm Hash digest
SHA256 10335e7c92e23356ce6da656e8fe2c7785d0f1be64aac8d5127fcb5f9c49cb7f
MD5 6867f33cfc1e0e63e93b99b35b3f542f
BLAKE2b-256 362eed1c9965d01df0310cba1aa6a78a75174df0d5aabe011f67927a4511c087

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_sohoui-1.3.8-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a84f05282a505bc15c8d9eada4f915597d7bf06ef6997b6b6edb7641626431dc
MD5 804d38a85d88edcdb8c481f1fafdc599
BLAKE2b-256 2160bdadecc7f886de3e5ccb491679ee471d11bf71729ca1294c0b8b151996de

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