先把后台配置好,各种坑呀

main
roger_home_pc 1 year ago
parent 5f99870a31
commit 91b30f3799
  1. 3
      apps/basic/__init__.py
  2. 14
      apps/basic/admin.py
  3. 1
      apps/basic/apps.py
  4. 3
      apps/goods/__init__.py
  5. 32
      apps/goods/admin.py
  6. 1
      apps/goods/apps.py
  7. 3
      apps/order/__init__.py
  8. 19
      apps/order/admin.py
  9. 3
      apps/order/apps.py
  10. 3
      apps/user/__init__.py
  11. 8
      apps/user/admin.py
  12. 1
      apps/user/apps.py
  13. 6
      apps/user/models.py

@ -0,0 +1,3 @@
from .apps import BasicConfig
default_app_config = 'apps.basic.BasicConfig'

@ -1,3 +1,17 @@
from django.contrib import admin
from apps.basic.models import Address
# Register your models here.
@admin.register(Address)
class AddressAdmin(admin.ModelAdmin):
admin.site.site_title = '我的特产商城后台'
admin.site.site_header = '我的特产商城后台'
admin.site.index_title = '商城平台管理'
# 设置列表显示列
list_display = ['province', 'city', 'district', 'address', 'contact_name', 'contact_mobile']
# 设置搜索
search_fields = ['contact_name', 'contact_mobile']
# 过滤
list_filter = ['city']

@ -5,3 +5,4 @@ class BasicConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
# name = 'basic'
name = 'apps.basic'
verbose_name = '基础信息管理' # 后台模块名称

@ -0,0 +1,3 @@
from .apps import GoodsConfig
default_app_config = 'apps.goods.GoodsConfig'

@ -1,3 +1,35 @@
from django.contrib import admin
from apps.goods.models import *
# Register your models here.
@admin.register(GoodsCategory)
class GoodsCategory(admin.ModelAdmin):
admin.site.site_title = '我的特产商城后台'
admin.site.site_header = '我的特产商城后台'
admin.site.index_title = '商城平台管理'
# 设置列表中显示的字段
list_display = ['name', 'logo', 'sort', 'create_time']
# 设置搜索条件
search_fields = ['name']
# 设置过滤
list_filter = ['name', 'parent_id']
# 设置日期选择器
data_hierarchy = 'create_time'
# 设置分页
list_per_page = 10
# 设置排序
ordering = ['sort']
@admin.register(Goods)
class GoodsAdmin(admin.ModelAdmin):
# 设置列表中显示哪些字段
list_display = ['name', 'market_price', 'price']
@admin.register(Slide)
class SlideAdmin(admin.ModelAdmin):
# 设置列表中显示哪些字段
list_display = ['goods_id', 'sort', 'images']

@ -5,3 +5,4 @@ class GoodsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
# name = 'goods'
name = 'apps.goods'
verbose_name = '商品管理' # 后台管理系统只显示的名称

@ -0,0 +1,3 @@
from .apps import OrderConfig
default_app_config = 'apps.order.OrderConfig'

@ -1,3 +1,22 @@
from django.contrib import admin
from apps.order.models import *
# Register your models here.
@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
# 设置列表中的显示项
list_display = ['order_id', 'order_total', 'order_price', 'memo']
@admin.register(OrderGoods)
class OrderGoodsAdmin(admin.ModelAdmin):
# 设置列表中的显示项
list_display = ['goods_id', 'goods_num', 'price']
@admin.register(Cart)
class CartAdmin(admin.ModelAdmin):
# 设置列表中的显示项
list_display = ['goods_id', 'user_id', 'goods_num']

@ -4,4 +4,5 @@ from django.apps import AppConfig
class OrderConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
# name = 'order'
name = 'apps.order'
name = 'apps.order' # 修改此处用户在settings中注册apps下的应用
verbose_name = '订单管理' # 后台管理系统中显示的模块名称

@ -0,0 +1,3 @@
from .apps import UserConfig
default_app_config = 'apps.user.UserConfig'

@ -1,3 +1,11 @@
from django.contrib import admin
from apps.user.models import MyUser
from django.contrib.auth.admin import UserAdmin
# 如果有继承关系此处要引用两个模型, 并且使用site.register
# Register your models here.
admin.site.register(MyUser, UserAdmin)
class MyUserAdmin(admin.ModelAdmin):
list_display = ['username', 'email', 'is_active', 'truename', 'mobile']

@ -5,3 +5,4 @@ class UserConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
# name = 'user'
name = 'apps.user'
verbose_name = '用户管理'

@ -23,12 +23,12 @@ class MyUser(AbstractUser):
true_name = models.CharField(verbose_name='真实姓名', max_length=50, blank=True)
mobile = models.CharField(verbose_name='手机号码', max_length=11, default='')
sex = models.IntegerField(verbose_name='性别', choices=SEX)
sex = models.IntegerField(verbose_name='性别', choices=SEX, default=0)
birthday = models.DateField(verbose_name='生日', blank=True, null=True)
nickname = models.CharField(verbose_name='昵称', max_length=50, blank=True)
user_img = models.ImageField(verbose_name='头像', upload_to='user_mage', default='')
level = models.IntegerField(verbose_name='用户级别', choices=LEVEL)
status = models.IntegerField(verbose_name='用户状态', choices=STATUS)
level = models.IntegerField(verbose_name='用户级别', choices=LEVEL, default=4)
status = models.IntegerField(verbose_name='用户状态', choices=STATUS,default=0)
create_time = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
update_time = models.DateTimeField(verbose_name='更新时间', auto_now=True)

Loading…
Cancel
Save