管理页面在django中没有显示list_display字段?

时间:2014-03-21 18:37:02

标签: django django-admin

我的admin page未显示fields中列出的admin.py

以下是admin.py

from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from customRegistration.models import ExUserProfile

    admin.site.unregister(User)

    class UserProfileInline(admin.StackedInline):
        model = ExUserProfile

    class UserProfileAdmin(UserAdmin):
        inlines = [ UserProfileInline, ]
        list_display = ('username', 'email','dateofBirth')

    admin.site.register(User, UserProfileAdmin)

我的管理页面上没有usernamedateofBirth field

models.py

from django.db import models
from registration.models import User
from registration.signals import user_registered

class ExUserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    ishuman = models.BooleanField(required=True)
    dateofBirth=models.DateField(required=True)

    def __unicode__(self):
        return self.user


def user_registered_callback(sender, user, request, **kwargs):
    profile = ExUserProfile(user = user)
    profile.ishuman = bool(request.POST["ishuman"])
    profile.dateofBirth=request.POST["dateofBirth"]
    print request.POST["dateofBirth"]
    profile.save()

user_registered.connect(user_registered_callback)

0 个答案:

没有答案