2013-11-01 2 views
0

관리자 패널에 django 앱에 로그인 할 수 없습니다. 오류를 반환합니다 (여기에 나열 : http://dpaste.com/1437248/).Django 관리자가 TypeError를 반환합니다.

내 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') 

편집 : 지금 나는이 오류가 관리자에 의해 발생한 것이 아닌지 확신합니다. py/Admin 클래스 - admin.py의 내용을 삭제했으며 오류가 여전히 있습니다.

+0

urls.py에'admin.autodiscover()'를 넣었습니까? –

+0

예, 두 줄의 주석 처리를 제거했습니다. – dease

+0

/admin /에게 귀하의 요청을 반복하여 마지막 역 추적 라인의 지역 주민을 조사하십시오. 어떤 함수가'processor' 변수에 저장되어 있습니까? 관리자 인터페이스가 아닌 문제처럼 보입니다. – werehuman

답변

0

모델 관리자 클래스는 모델 Product 안에 있으면 안됩니다. 그것을 admin.py에 정의하십시오.

from app.models import * 
from django.contrib import admin 

class ProductAdmin(admin.ModelAdmin): 
    list_display = ('title','price') 

admin.site.register(Product, ProductAdmin) 
+0

아무 것도 고치지 않지만 여전히 같은 오류가 발생합니다. – dease

관련 문제