installation fixture django-municipios - python

I am getting the following error when executing the command python manage.py loaddata municipios_geo_2013_4674.json.bz2 or python manage.py loaddata municipios_geo_2013_4674.json. How to solve the AttributeError?
Package and json in: https://github.com/znc-sistemas/django-municipios
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 109, in loaddata
self.load_label(fixture_label)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 175, in load_label
obj.save(using=self.using)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/core/serializers/base.py", line 205, in save
models.Model.save_base(self.object, using=using, raw=True, **kwargs)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 837, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 904, in _save_table
forced_update)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/base.py", line 954, in _do_update
return filtered._update(values) > 0
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/query.py", line 664, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1191, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 863, in execute_sql
sql, params = self.as_sql()
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py", line 1157, in as_sql
val = field.get_db_prep_save(val, connection=self.connection)
File "/Users/lidiane/Developer/django/integra-fundaj/.myvenv/lib/python3.5/site-packages/django/contrib/gis/db/models/fields.py", line 182, in get_db_prep_save
return connection.ops.Adapter(self.get_prep_value(value))
AttributeError: Problem installing fixture '/Users/lidiane/Developer/django/integra-fundaj/municipios_geo_2013_4674.json': 'DatabaseOperations' object has no attribute 'Adapter'

Related

Django when running tests ValueError: Related model cannot be resolved. Related to previous migrations issue

Had an issue with django migration files not syncing with the db (was getting column not found) due to a Model being renamed. I don't completely understand migrations but after following different stackoverflow answers - performing fake zero migrations and then adding the manual migration file:
# Generated by Django 4.1 on 2022-10-10 00:47
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('campaigns', '0015_blah_blah'),
]
operations = [
migrations.RenameModel("PreviousModelName", "ModelName")
]
I thought the issue had been fixed. I can query the database without errors, I can add new fields to the renamed model and migrate them. Everything seemed to be working. But now I've realised that when I run python manage.py test I get the following error:
Traceback (most recent call last):
File "/code/manage.py", line 25, in <module>
main()
File "/code/manage.py", line 21, in main
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
super().run_from_argv(argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 402, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/test.py", line 68, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/local/lib/python3.9/site-packages/django/test/runner.py", line 1045, in run_tests
old_config = self.setup_databases(
File "/usr/local/lib/python3.9/site-packages/django/test/runner.py", line 941, in setup_databases
return _setup_databases(
File "/usr/local/lib/python3.9/site-packages/django/test/utils.py", line 220, in setup_databases
connection.creation.create_test_db(
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/creation.py", line 78, in create_test_db
call_command(
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 198, in call_command
return command.execute(*args, **defaults)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 448, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 96, in wrapped
res = handle_func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 349, in handle
post_migrate_state = executor.migrate(
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/migration.py", line 130, in apply
operation.database_forwards(
File "/usr/local/lib/python3.9/site-packages/django/db/migrations/operations/models.py", line 96, in database_forwards
schema_editor.create_model(model)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 442, in create_model
sql, params = self.table_sql(model)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 216, in table_sql
definition, extra_params = self.column_sql(model, field)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/schema.py", line 346, in column_sql
field_db_params = field.db_parameters(connection=self.connection)
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 1183, in db_parameters
target_db_parameters = self.target_field.db_parameters(connection)
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 1060, in target_field
return self.foreign_related_fields[0]
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 747, in foreign_related_fields
rhs_field for lhs_field, rhs_field in self.related_fields if rhs_field
File "/usr/local/lib/python3.9/site-packages/django/utils/functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 734, in related_fields
return self.resolve_related_fields()
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 1103, in resolve_related_fields
related_fields = super().resolve_related_fields()
File "/usr/local/lib/python3.9/site-packages/django/db/models/fields/related.py", line 712, in resolve_related_fields
raise ValueError(
ValueError: Related model 'app.modelname' cannot be resolved
It seems like it throws an error when trying to create the test database. Is there something I need to do to sync the test database?
First delete all migration files and migrate apps manually by doing below command:
python manage.py makemigrations appname
python manage.py sqlmigrate appname 0001 #This value will generate after makemigration.
python manage.py migrate
Hope this will solve your error.

I'm suddently not able to run server manage.py django since I upgrade my PyCharm

I can run server to test my webapp. Since I upgrade my PyCharm I cant run it.
I dont know how to do
Bellow is the error output
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 301, in run
self.run_loop()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop
next(ticker)
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 347, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 363, in snapshot_files
for file in self.watched_files():
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\migue\PycharmProjects\research4medjango\venv\lib\site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files
if not path.exists():
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 1291, in exists
self.stat()
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 1111, in stat
return self._accessor.stat(self)
File "C:\Users\migue\AppData\Local\Programs\Python\Python35-32\lib\pathlib.py", line 371, in wrapped
return strfunc(str(pathobj), *args)
OSError: [WinError 123] (File name, directory name or volume label syntax incorrect) when using __file__ '<frozen importlib._bootstrap>'

AttributeError: 'str' object has no attribute '_meta' / Python 3.6

Error traceback for AttributeError:
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
utility.execute()
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 327, in execute
self.check()
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\checks.py", line 25, in check_admin_app
errors.extend(site.check(app_configs))
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\sites.py", line 81, in check
errors.extend(modeladmin.check())
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\options.py", line 117, in check
return self.checks_class().check(self, **kwargs)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\checks.py", line 526, in check
errors.extend(self._check_list_filter(admin_obj))
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\checks.py", line 697, in _check_list_filter
for index, item in enumerate(obj.list_filter)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\checks.py", line 697, in <listcomp>
for index, item in enumerate(obj.list_filter)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\checks.py", line 740, in _check_list_filter_item
get_fields_from_path(model, field)
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\utils.py", line 500, in get_fields_from_path
parent = get_model_from_relation(fields[-1])
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\utils.py", line 451, in get_model_from_relation
return field.get_path_info()[-1].to_opts.model
File "C:\Users\INUSCG\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\fields\related.py", line 723, in get_path_info
opts = self.remote_field.model._meta
AttributeError: 'str' object has no attribute '_meta'
I am facing this Error on python 3.6, I got this error when i migrate my django project
IT's Django version problem
I installed python 3.8with appropriate Django version
Its working for me

Pytest ImportError no module named 'test'

I am trying to run pytest on CircleCI, locally I have no issues but when I execute the shell command
PYTHONPATH=. pytest --cov-report html:$CIRCLE_ARTIFACTS/htmlcov --nomigrations
I get the following traceback:
Traceback (most recent call last):
File "/home/ubuntu/virtualenvs/venv-2.7.12/bin/pytest", line 11, in <module>
sys.exit(main())
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 49, in main
config = _prepareconfig(args, plugins)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 168, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
wrap_controller.send(call_outcome)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/helpconfig.py", line 68, in pytest_cmdline_parse
config = outcome.get_result()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 280, in get_result
_reraise(*ex) # noqa
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 957, in pytest_cmdline_parse
self.parse(args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 1121, in parse
self._preparse(args, addopts=addopts)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/config.py", line 1092, in _preparse
args=args, parser=self._parser)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
return _wrapped_call(hook_impl.function(*args), self.execute)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 254, in _wrapped_call
return call_outcome.get_result()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 280, in get_result
_reraise(*ex) # noqa
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
self.result = func()
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
res = hook_impl.function(*args)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/pytest_django/plugin.py", line 244, in pytest_load_initial_conftests
dj_settings.DATABASES
File "/opt/circleci/python/2.7.12/lib/python2.7/contextlib.py", line 35, in __exit__
self.gen.throw(type, value, traceback)
File "/home/ubuntu/virtualenvs/venv-2.7.12/lib/python2.7/site-packages/pytest_django/plugin.py", line 117, in _handle_import_error
raise ImportError(msg)
ImportError: No module named test
pytest-django found a Django project in /home/ubuntu/rit-das-pdp (it contains manage.py) and added it to the Python path.
If this is wrong, add "django_find_project = false" to pytest.ini and explicitly manage your Python path.
PYTHONPATH=. pytest --cov-report html:$CIRCLE_ARTIFACTS/htmlcov --nomigrations returned exit code 1
I have no idea what the error is saying or how to debug it.

python manage.py migrate KeyError: 255

Server environment configuration
Ubuntu 14
Django 1.11.3
Python 3.6.1
MySql 8.0.1
When I execute python manage.py dbshell command everything works ok.
But when I execute python manage.py migrate command, I get a KeyError: 255.
Here is the traceback:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/makemigrations.py", line 110, in handle
loader.check_consistent_history(connection)
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/loader.py", line 282, in check_consistent_history
applied = recorder.applied_migrations()
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
self.ensure_schema()
File "/usr/local/lib/python3.6/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 254, in cursor
return self._cursor()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 229, in _cursor
self.ensure_connection()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
self.connect()
File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/base.py", line 189, in connect
self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 274, in get_new_connection
conn = Database.connect(**conn_params)
File "/usr/local/lib/python3.6/site-packages/pymysql/__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 706, in __init__
self.connect()
File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 931, in connect
self._get_server_information()
File "/usr/local/lib/python3.6/site-packages/pymysql/connections.py", line 1269, in _get_server_information
self.server_charset = charset_by_id(lang).name
File "/usr/local/lib/python3.6/site-packages/pymysql/charset.py", line 38, in by_id
return self._by_id[id]
KeyError: 255
moduleļ¼š
from django.db import models
class UserInfo (models.Model):
name = models.CharField(max_length=10)
tel = models.CharField(max_length=10)
use
manage.py makemigrations
then
manage.py migrate
You need to give the modal's code by the way.

Categories