我的模型.py
from django.db import models
from django.contrib.auth.models import User
class Song(models.Model):
uploader = models.ForeignKey(User)
date_uploaded = models.DateTimeField(auto_now=True)
song_file = models.FileField(upload_to='music/', max_length=100)
artist = models.CharField(max_length=75, blank=True)
title = models.CharField(max_length=100, blank=True)
genre = models.CharField(max_length=100, blank=True)
def __unicode__(self):
return u'%s' % (self.song_file)
我的管理员.py
from django.contrib import admin
from uploader.models import Song
from django.db import models
class SongAdmin(admin.ModelAdmin):
list_display = ('song_file', 'title', 'artist', 'genre', 'uploader')
search_fields = ('song_file', 'uploader', 'genre', 'title')
fields = ('song_file', 'title', 'artist', 'genre')
admin.site.register(Song, SongAdmin)
该文件被上传(我在我的媒体文件夹中看到它),但它没有显示在我的管理页面中,当文件上传时,我得到:
'bool' object has no attribute 'has_header' when uploading via a FileField in my admin
我在这里遗漏了一些明显的东西吗?对django来说很新。