Я пытаюсь перенести свои приложения из py2 в py3, и я сталкиваюсь с этой ошибкой при запуске сценариев миграции. После некоторого копания я получаю ту же ошибку при выполнении MyModel.objects.get(id=<some_id>)
Теперь я знаю, что StrginType
устарел в python3, и я удалил все basestring
и заменил на string
в моих скриптах (не уверенесли связано), но я не уверен, где эта ошибка вызывается. Я использую Django 1.11, поэтому он должен быть совместимым.
Кажется, это что-то из Django, но я не могу понять, что именно. Я искал на django doc и ничего не получил.
Кто-нибудь сталкивался с такой же ошибкой раньше, когда получал объект через django?
РЕДАКТИРОВАТЬ:
full traceback
Traceback (most recent call last):
File "manage.py", line 45, in <module>
main()
File "manage.py", line 41, in main
execute_from_command_line(sys.argv)
File "<some_domain>/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "<some_domain>/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "<some_domain>/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "<some_domain>/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "<some_domain>/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "<some_domain>/lib/python3.6/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "<some_domain>/lib/python3.6/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "<some_domain>/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "<some_domain>/lib/python3.6/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "<some_domain>/lib/python3.6/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "<some_domain>/<path_to_migration>/migrations/<migration file>.py", line 10, in <some module>
<some model name> = apps.get_model(<someapp>, <some_model>)
File "<some_domain>/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __iter__
self._fetch_all()
File "<some_domain>/lib/python3.6/site-packages/django/db/models/query.py", line 1102, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "<some_domain>/lib/python3.6/site-packages/django/db/models/query.py", line 62, in __iter__
for row in compiler.results_iter(results):
File "<some_domain>/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 834, in results_iter
row = self.apply_converters(row, converters)
File "<some_domain>/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 819, in apply_converters
value = converter(value, expression, self.connection, self.query.context)
File "<some_domain>/lib/python3.6/site-packages/encrypted_fields/fields.py", line 160, in from_db_value
return self.to_python(value)
File "<some_domain>/lib/python3.6/site-packages/encrypted_fields/fields.py", line 163, in to_python
if value is None or not isinstance(value, types.StringTypes):
AttributeError: module 'types' has no attribute 'StringTypes'