我无法登录 django 应用程序的管理面板。它返回错误(在此处列出:http: //dpaste.com/1437248/)。
我的 admin.py:
from app.models import *
from django.contrib import admin
admin.site.register(Product, Product.Admin)
我的models.py(部分):
class Product(BaseModel):
company = models.ForeignKey(Company, null=True, blank=True)
title = models.CharField(max_length=128)
description = models.TextField()
category = models.ForeignKey(ProductCategory, null=True, blank=True)
price = models.DecimalField(max_digits=5,decimal_places=2)
image = models.ImageField(upload_to=product_upload_to)
thumb = models.ImageField(upload_to=thumb_upload_to)
def save(self, force_update=False, force_insert=False, thumb_size=(120,120)):
image = Image.open(self.image)
image.thumbnail(thumb_size, Image.ANTIALIAS)
temp_handle = StringIO()
image.save(temp_handle, 'png')
temp_handle.seek(0) # rewind the file
suf = SimpleUploadedFile(os.path.split(self.image.name)[-1],
temp_handle.read(),
content_type='image/png')
self.thumb.save(suf.name+'.png', suf, save=False)
super(Product, self).save(force_update, force_insert)
class Admin(admin.ModelAdmin):
list_display = ('title','price')
编辑: 现在我确定这个错误不是由 admin.py/Admin 类引起的 - 我删除了 admin.py 的内容并且错误仍然存在。