django管理员注册没有出现

时间:2015-04-09 01:43:39

标签: django

我开始了一个django教程" http://www.lightbird.net/dbe/photo.html",并按照其2个应用程序的说明进行操作,但两个都没有。我试图在管理员中注册这些模型,我在管理页面上看到的是"身份验证和授权,组,用户"堆叠在一起。我的相册,标签和图片管理员在哪里?我在启动runserver

之前运行了syncdb
from django.db import models
from django.contrib import admin
from django.contrib.auth.model import User

class Album(models.Model):
    title   = models.CharField(max_length=60)
    public  = models.BooleanField(default=False)
    def __unicode__(self):
        return self.title

class Tag(models.Model):
    tag = models.CharField(max_length=50)
    def __unicode__(self):
        return self.tag

class Image(models.Model)
    title       = models.CharField(max_length=60, blank=True, null=True)
    image       = models.FileField(upload_to="images/")
    tags        = models.ManyToManyField(Tag, blank=True)
    albums      = models.ManyToManyField(Album, blank=True)
    created     = models.DateTimeField(auto_now_add=True)
    rating      = models.IntegerField(default=50)
    width       = models.IntegerField(blank=True, null=True)
    height      = models.IntegerField(blank=True, null=True)
    user        = models.ForeignKey(User, blank=True, null=True)

    def __unicode__(self):
        return self.image.name

class AlbumAdmin(admin.ModelAdmin):
    search_field    = ["title"]
    list_display    = ["title"]

class TagAdmin(admin.ModelAdmin):
    list_display = ["tag"]

class ImageAdmin(admin.ModelAdmin):
    search_fields   = ["title"]
    list_display    = ["__unicode__", "title", "user", "rating", "created"]
    list_filter     = ["tags", "albums"]

admin.site.register(Album, AlbumAdmin)
admin.site.register(Tag, TagAdmin)
admin.site.register(Image, ImageAdmin)

0 个答案:

没有答案