Django踩坑记录3

Posted hy546880109

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Django踩坑记录3相关的知识,希望对你有一定的参考价值。

路径如下:

技术图片

admin.py的代码:

from django.contrib import admin
from sign.models import Event,Guest
# Register your models here.
class EventAdmin(admin.ModelAdmin):
    list_display = [id,name,status,address,start_time]

class GuestAdmin(admin.ModelAdmin):
    list_display = [realname,phone,email,sign,create_time,event]

admin.site.register(Event.EventAdmin)
admin.site.register(Guest.GuestAdmin)

错误:

技术图片

 

 解决办法:

from django.contrib import admin
from .models import Event,Guest


# Register your models here.
class EventAdmin(admin.ModelAdmin):
    list_display = [id, name, status, address, start_time]


class GuestAdmin(admin.ModelAdmin):
    list_display = [realname, phone, email, sign, create_time, event]


admin.site.register(Event,EventAdmin)
admin.site.register(Guest,GuestAdmin)

原因分析:

1:导包路径错误,同一路径下用 from .models import *

2:   逗号写成点号。  应该是   admin.site.register(Event,EventAdmin)           admin.site.register(Guest,GuestAdmin)



以上是关于Django踩坑记录3的主要内容,如果未能解决你的问题,请参考以下文章

Fastlane 一键打包/发布APP - 使用记录及踩坑

Fastlane 一键打包/发布APP - 使用记录及踩坑

关于django中间件使用的踩坑经历

centos部署flask+nginx+uwsgi之踩坑指南

Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you ha

Django踩坑之django.core.exceptions.ImproperlyConfigured mysqlclient 1.3.13 or newer is required; you ha