Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_45031851
simpleui_demo
提交
57a31546
S
simpleui_demo
项目概览
weixin_45031851
/
simpleui_demo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
simpleui_demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
57a31546
编写于
4月 15, 2019
作者:
N
newpanjing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add readme.md
上级
90f49c0f
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
128 addition
and
17 deletion
+128
-17
README.md
README.md
+9
-7
db.sqlite3
db.sqlite3
+0
-0
demo/__init__.py
demo/__init__.py
+1
-0
demo/admin.py
demo/admin.py
+46
-0
demo/apps.py
demo/apps.py
+1
-0
demo/models.py
demo/models.py
+46
-0
simpleui_demo/settings.py
simpleui_demo/settings.py
+22
-10
simpleui_demo/urls.py
simpleui_demo/urls.py
+3
-0
未找到文件。
README.md
浏览文件 @
57a31546
...
...
@@ -4,13 +4,15 @@ django simpleui demo.
## setup
```
#runserver
python manage.py runserver 8000
pip install django django-simpleui
#open browser
http://127.0.0.1:8000/admin
python manage.py runserver 8000
#username and password
simpleui 123456
```
#open browser
http://127.0.0.1:8000/admin
```
\ No newline at end of file
username and password:
>simpleui 123456
\ No newline at end of file
db.sqlite3
浏览文件 @
57a31546
无法预览此类型文件
demo/__init__.py
浏览文件 @
57a31546
default_app_config
=
'demo.apps.DemoConfig'
demo/admin.py
浏览文件 @
57a31546
from
django.contrib
import
admin
from
.models
import
*
# Register your models here.
@
admin
.
register
(
Department
)
class
DepartmentAdmin
(
admin
.
ModelAdmin
):
# 要显示的字段
list_display
=
(
'id'
,
'name'
,
'create_time'
)
# 需要搜索的字段
search_fields
=
(
'name'
,)
# 分页显示,一页的数量
list_per_page
=
10
actions_on_top
=
True
@
admin
.
register
(
Employe
)
class
EmployeAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'id'
,
'name'
,
'gender'
,
'idCard'
,
'phone'
,
'birthday'
,
'department'
,
'enable'
,
'create_time'
)
search_fields
=
(
'name'
,
'enable'
)
list_per_page
=
10
list_filter
=
(
'department'
,
'create_time'
,
'birthday'
,
'time'
,
'enable'
,
'gender'
)
list_display_links
=
(
'name'
,
'idCard'
)
list_editable
=
(
'department'
,
'phone'
,
'birthday'
,
'enable'
,
'gender'
)
date_hierarchy
=
'create_time'
# 增加自定义按钮
actions
=
[
'make_copy'
]
def
make_copy
(
self
,
request
,
queryset
):
ids
=
request
.
POST
.
getlist
(
'_selected_action'
)
for
id
in
ids
:
employe
=
Employe
.
objects
.
get
(
id
=
id
)
Employe
.
objects
.
create
(
name
=
employe
.
name
,
idCard
=
employe
.
idCard
,
phone
=
employe
.
phone
,
birthday
=
employe
.
birthday
,
department_id
=
employe
.
department_id
)
make_copy
.
short_description
=
'复制员工'
demo/apps.py
浏览文件 @
57a31546
...
...
@@ -3,3 +3,4 @@ from django.apps import AppConfig
class
DemoConfig
(
AppConfig
):
name
=
'demo'
verbose_name
=
'综合管理'
demo/models.py
浏览文件 @
57a31546
from
django.db
import
models
# Create your models here.
class
Department
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'部门名'
,
help_text
=
'一个部门的名字应该唯一'
,
unique
=
True
,
db_index
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
'创建时间'
,
auto_now
=
True
)
class
Meta
:
verbose_name
=
"部门"
verbose_name_plural
=
"部门管理"
def
__str__
(
self
):
return
self
.
name
class
Employe
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
'名称'
,
help_text
=
'员工的名字'
,
null
=
False
,
blank
=
False
,
db_index
=
True
)
gender_choices
=
(
(
0
,
'未知'
),
(
1
,
'男'
),
(
2
,
'女'
),
)
gender
=
models
.
IntegerField
(
choices
=
gender_choices
,
verbose_name
=
'性别'
,
default
=
0
)
idCard
=
models
.
CharField
(
max_length
=
18
,
verbose_name
=
'身份证号'
,
help_text
=
'18位的身份证号码'
,
blank
=
True
,
null
=
True
)
phone
=
models
.
CharField
(
max_length
=
11
,
verbose_name
=
'手机号'
)
birthday
=
models
.
DateField
(
verbose_name
=
'生日'
)
time
=
models
.
TimeField
(
verbose_name
=
'时间'
,
auto_now
=
True
)
department
=
models
.
ForeignKey
(
Department
,
on_delete
=
models
.
SET_NULL
,
blank
=
False
,
null
=
True
,
verbose_name
=
'部门'
,
db_index
=
True
)
enable
=
models
.
BooleanField
(
verbose_name
=
'状态'
,
default
=
True
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
'创建时间'
,
auto_now
=
True
)
update_time
=
models
.
DateTimeField
(
verbose_name
=
'更新时间'
,
auto_now
=
True
)
class
Meta
:
verbose_name
=
"员工"
verbose_name_plural
=
"员工管理"
def
__str__
(
self
):
return
self
.
name
simpleui_demo/settings.py
浏览文件 @
57a31546
...
...
@@ -15,7 +15,6 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
...
...
@@ -25,8 +24,7 @@ SECRET_KEY = '&%up9@!s_$$4(qurnori=vit2#kg!bzs$_+m64^j$2-vzibx&p'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
ALLOWED_HOSTS
=
[
'*'
,]
ALLOWED_HOSTS
=
[
'*'
,
]
# Application definition
...
...
@@ -38,7 +36,10 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'demo.apps.DemoConfig'
,
# 'demo.apps.DemoConfig',
# 注册自己的app
'demo'
,
'finance'
,
]
MIDDLEWARE
=
[
...
...
@@ -56,8 +57,7 @@ ROOT_URLCONF = 'simpleui_demo.urls'
TEMPLATES
=
[
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)]
,
'DIRS'
:
[
os
.
path
.
join
(
BASE_DIR
,
'templates'
)],
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
...
...
@@ -72,7 +72,6 @@ TEMPLATES = [
WSGI_APPLICATION
=
'simpleui_demo.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
...
...
@@ -83,7 +82,6 @@ DATABASES = {
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
...
...
@@ -102,11 +100,12 @@ AUTH_PASSWORD_VALIDATORS = [
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE
=
'zh-hans'
# LANGUAGE_CODE = 'en-us'
TIME_ZONE
=
'Asia/Shanghai'
...
...
@@ -116,8 +115,21 @@ USE_L10N = True
USE_TZ
=
True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL
=
'/static/'
# STATICFILES_DIRS = [
# os.path.join(BASE_DIR, "static"),
# ]
STATIC_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
"static"
)
# simpleui 设置
# 首页配置
# SIMPLEUI_HOME_PAGE = 'https://www.baidu.com'
# 首页标题
# SIMPLEUI_HOME_TITLE = '百度一下你就知道'
# 首页图标,支持element-ui的图片和fontawesome的图标
# SIMPLEUI_HOME_ICON = 'el-icon-date'
simpleui_demo/urls.py
浏览文件 @
57a31546
...
...
@@ -16,6 +16,9 @@ Including another URLconf
from
django.contrib
import
admin
from
django.urls
import
path
admin
.
site
.
site_title
=
'管理后台'
admin
.
site
.
site_header
=
'员工管理后台'
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录