Django 1.7で実行していますが、python manage.pymigrateを実行すると次のエラーが発生します
File "/home/ymorin007/workspace/sites/jantiyes.com/src/deeds/migrations/0006_auto_20141204_1631.py", line 9, in <module>
class Migration(migrations.Migration):
File "/home/ymorin007/workspace/sites/jantiyes.com/src/deeds/migrations/0006_auto_20141204_1631.py", line 19, in Migration
field=models.ImageField(storage=django.core.files.storage.FileSystemStorage(location=bPath('/home/ymorin007/workspace/sites/jantiyes.com/src/media')), max_length=255, null=True, upload_to=deeds.models.picture_name, blank=True),
NameError: name 'bPath' is not defined
from jantiyes.settings.base import MEDIA_ROOT
upload_storage = FileSystemStorage(location=MEDIA_ROOT)
def picture_name(self, filename):
ext = filename.split('.')[-1]
deedname = re.sub('[ ]', '-', self.text.lower())
filename = "DEED-%s-%s.%s" % (self.id, deedname, ext)
url = "%s" % filename
return url
class Deed(TimeStampedModel):
picture = models.ImageField(upload_to=picture_name, null=True, blank=True, storage=upload_storage, max_length=255)
text = models.CharField(max_length=500)
when = models.DateField(unique=True)
私のメディア宣言:
BASE_DIR = Path(__file__).ancestor(3)
MEDIA_ROOT = BASE_DIR.child("media")
の正確な定義なしで見分けるのは難しいですjantiyes.settings.base.MEDIA_ROOT
が、それは分解bPath
不可能であり、のサブクラスであるクラス()のインスタンスだと思います。したがって、移行ライターは、インポートを必要とせず、値がであると想定します。unicode
repr
bPath('/home/ymorin007/workspace/sites/jantiyes.com/src/media')
2つのオプションがあります。
jantiyes.settings.base.MEDIA_ROOT
文字列として定義されていることを確認してください。したがって、移行ライターによって正しく処理されます。たとえばMEDIA_ROOT = '/home/ymorin007/workspace/sites/jantiyes.com/src/media'
、jantiyes.settings.base
モジュールファイル内。bPath
クラスが分解可能であることを確認deconstruct
します。この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加