2016-10-17 71 views
0

我正在將現有模型/ admin轉換爲django-polymorphic。我認爲我已經成功完成了模型和遷移(至少,它在shell中工作),但我無法讓管理員工作。我發現documentation有點模糊,但我想我已經正確地遵循了它。異常值:類型'PolymorphicModelBase'的對象沒有len()

class LibraryItemAdmin(PolymorphicParentModelAdmin): 
    base_model = LibraryItem 
    child_models = (Whitepaper) 


class LibraryItemChildAdmin(PolymorphicChildModelAdmin): 
    base_model = LibraryItem 


class WhitepaperAdmin(LibraryItemChildAdmin): 
    form = LibraryForm 
    base_model = Whitepaper 

我不明白的問題:

Traceback: 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 
    108.     response = middleware_method(request) 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/middleware/common.py" in process_request 
    74.    if (not urlresolvers.is_valid_path(request.path_info, urlconf) and 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in is_valid_path 
    646.   resolve(path, urlconf) 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve 
    521.  return get_resolver(urlconf).resolve(path) 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve 
    365.    for pattern in self.url_patterns: 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns 
    401.   patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module 
    395.    self._urlconf_module = import_module(self.urlconf_name) 
File "/usr/lib/python2.7/importlib/__init__.py" in import_module 
    37.  __import__(name) 
File "/srv/www/urls.py" in <module> 
    349.  url(r'^admin/', include(admin.site.urls), name='admin'), 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in urls 
    291.   return self.get_urls(), 'admin', self.name 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in get_urls 
    275.     url(r'^%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls)), 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in urls 
    631.   return self.get_urls() 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/polymorphic/admin/parentadmin.py" in get_urls 
    283.   self._lazy_setup() 
File "/root/.virtualenvs/divesite/local/lib/python2.7/site-packages/polymorphic/admin/parentadmin.py" in _lazy_setup 
    92.   self._compat_mode = len(child_models) and isinstance(child_models[0], (list, tuple)) 

Exception Type: TypeError at /admin/library 
Exception Value: object of type 'PolymorphicModelBase' has no len() 

回答

相關問題