さまざまなアプリで定義されているすべてのモデルの基本クラスを追加しようとしています。次のようにパッケージを作成しましたlib/base.py
:
from django.db import models
import logging
# Get an instance of a logger
logger = logging.getLogger(__name__)
class Base(models.Model):
class Meta:
abstract = True
別のホームアプリディレクトリで、この基本モデルを使用したいと思います:
from django.db import models
from libs.base import Base
# Create your models here.
class Home(Base):
msg = models.CharField(max_length=100)
@classmethod
def create(cls, msg):
home = cls(msg=msg)
# do something with the book
return home
サーバーを実行すると、次のエラーが発生します。
File "/Users/.../home/models.py", line 2, in <module>
from libs.base import Base
ImportError: No module named libs.base
ここで欠けているものが見つかりませんか?