我收到此错误,但我不确定BasicModel
的来源。
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/seanna/pdenv/lib/python3.4/site-packages/django/db/models/manager.py", line 264, in __get__
self.model._meta.object_name,
AttributeError: Manager isn't available; BasicModel is abstract
当我尝试通过管理员或通过应用程序本身添加模型时,这是我收到的错误。
from shared.utils import *
class Forum(BaseModel):
title = CharField(max_length=60)
def __unicode__(self):
return self.title
这是我使用BaseModel的地方 在shared.utils中:
class BasicModel(Model):
class Meta: abstract = True
obj = objects = Manager()
def update(self, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
self.save()
BaseModel = BasicModel # TODO: rename all views to BaseModel
我不确定为什么BaseModel = BasicModel
以及它实际上做了什么,但这给我添加模型时出错。