私はエラーを取り除こうとしていますが、それを修正する手がかりを見つけることができませんでした。私は異なるパッケージでいくつかの修正を見たことがあるが、それらのどれも関連性がないので、助言してください。django.db.modelsからSubfieldBaseをインポートできません。SubfieldBase
トレースバック:私のCatalougeパッケージで
Traceback (most recent call last):
File "C:\Users\AliKhan\supermarekt\market\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
367, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
341, in execute
django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 85, in popu
late
app_config = AppConfig.create(entry)
File "C:\Python27\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\AliKhan\supermarekt\market\catalogue\__init__.py", line 4, in
<module>
from django.db.models import SubfieldBase
ImportError: cannot import name SubfieldBase
私は単にそれを輸入してきたし、インポートが失敗してきています。
from django.core.exceptions import ImproperlyConfigured
from django.db.models.fields import CharField, DecimalField
from django.db.models import SubfieldBase
from django.utils import six
from django.utils.translation import ugettext_lazy as _
SubfieldBaseのためのDjangoのソースコードは、Djangoのバージョン1.8.16用djagno.db.models.subclassing.pyである以下のとおりです。
import warnings
from django.utils.deprecation import RemovedInDjango110Warning
class SubfieldBase(type):
"""
A metaclass for custom Field subclasses. This ensures the model's attribute
has the descriptor protocol attached to it.
"""
def __new__(cls, name, bases, attrs):
warnings.warn("SubfieldBase has been deprecated. Use Field.from_db_value instead.",
RemovedInDjango110Warning, stacklevel=2)
new_class = super(SubfieldBase, cls).__new__(cls, name, bases, attrs)
new_class.contribute_to_class = make_contrib(
new_class, attrs.get('contribute_to_class')
)
return new_class
投稿したばかりのコードを読んでいますか?それはそのクラスに何が起こったのかについての非常に明確な記述を持っています。 –
しかし、それはインポートエラーをポップアップする必要がありますか? –
Django 1.10では、はい。 –