I have provisioned many servers and deployed this project many times, but this is the first time I have come across this issue.
I can connect to MySQL via command line and Sequel Pro just fine, it's only the Django specific commands that are producing this error.
(Staging)optimal#Simon:/var/virtualenvs/Staging/app$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/core/management/validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/var/virtualenvs/Staging/releases/20130204145734/apps/orpheus/files/models.py", line 17, in <module>
from orpheus.orders.models import Order
File "/var/virtualenvs/Staging/releases/20130204145734/apps/orpheus/orders/models.py", line 29, in <module>
from orpheus.variable_images.models import Newsletter
File "/var/virtualenvs/Staging/releases/20130204145734/apps/orpheus/variable_images/models.py", line 144, in <module>
class Topper(mixins.ModifiedDates):
File "/var/virtualenvs/Staging/releases/20130204145734/apps/orpheus/variable_images/models.py", line 149, in Topper
file = CouchDBFileField(storage=LongTermStorage(), blank=True)
File "/var/virtualenvs/Staging/releases/20130204145734/apps/orpheus/files/storage.py", line 183, in __init__
self.db = server[kwargs.get('database')]
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/couchdb/client.py", line 137, in __getitem__
db.resource.head() # actually make a request to the database
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/couchdb/http.py", line 377, in head
return self._request('HEAD', path, headers=headers, **params)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/couchdb/http.py", line 419, in _request
credentials=self.credentials)
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/couchdb/http.py", line 239, in request
resp = _try_request_with_retries(iter(self.retry_delays))
File "/var/virtualenvs/Staging/lib/python2.7/site-packages/couchdb/http.py", line 205, in _try_request_with_retries
raise e
socket.error: [Errno 111] Connection refused
I'm just hoping there is an obvious solution that I am overlooking. Hopefully someone else has ran into this problem, I didn't find anything using Google.
Related
$ docker-compose exec myapp python manage.py migrate
I've got this error after modifying my model, how can I rollback or fix the issue ?
Traceback (most recent call last):
File "/src/manage.py", line 21, in <module>
main()
File "/src/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/opt/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/opt/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/venv/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/venv/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/opt/venv/lib/python3.10/site-packages/django/core/management/base.py", line 89, in wrapped
res = handle_func(*args, **kwargs)
File "/opt/venv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 268, in handle
emit_post_migrate_signal(
File "/opt/venv/lib/python3.10/site-packages/django/core/management/sql.py", line 42, in emit_post_migrate_signal
models.signals.post_migrate.send(
File "/opt/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 180, in send
return [
File "/opt/venv/lib/python3.10/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/opt/venv/lib/python3.10/site-packages/adminactions/models.py", line 9, in create_extra_permissions_handler
p.create_extra_permissions()
File "/opt/venv/lib/python3.10/site-packages/adminactions/perms.py", line 34, in create_extra_permissions
content_types = ContentType.objects.get_for_models(*models)
File "/opt/venv/lib/python3.10/site-packages/django/contrib/contenttypes/models.py", line 89, in get_for_models
opts_models = needed_opts.pop(ct.model_class()._meta, [])
AttributeError: 'NoneType' object has no attribute '_meta'
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.
I have a local python environment working, but when I try and load in initial data.
python manage.py loaddata initial_data.json
I get an error about "RemovedInDjango18Warning"?
I am not a python dev to say - so this error is new to me.
C:\Python27\aasoo>python manage.py loaddata initial_data.json
C:\Python27\lib\site-packages\djorm_pgfulltext\models.py:323: RemovedInDjango18Warning: `SearchManagerMixIn.get_query_set` method should be renamed `get_queryset`.
class SearchManager(SearchManagerMixIn, models.Manager):
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 338, in execute
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\modeltranslation\management\commands\loaddata.py", line 50, in handle
return super(Command, self).handle(*fixture_labels, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 61, in handle
self.loaddata(fixture_labels)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 91, in loaddata
self.load_label(fixture_label)
File "C:\Python27\lib\site-packages\django\core\management\commands\loaddata.py", line 142, in load_label
for obj in objects:
File "C:\Python27\lib\site-packages\django\core\serializers\json.py", line 81, in Deserializer
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
File "C:\Python27\lib\site-packages\django\core\serializers\json.py", line 75, in Deserializer
for obj in PythonDeserializer(objects, **options):
File "C:\Python27\lib\site-packages\django\core\serializers\python.py", line 122, in Deserializer
m2m_data[field.name] = [m2m_convert(pk) for pk in field_value]
django.core.serializers.base.DeserializationError: Problem installing fixture 'C:\Python27\aasoo\content\fixtures\initial_data.json': 'int' object is not iterable
C:\Python27\aasoo>
You should rename get_query_set to get_queryset in SearchManagerMixIn. Can you paste the definition of the class if you need more help.
This was the traceback, please help.
Traceback (most recent call last):
File "C:\Documents and Settings\EC.32-SAMUEL\workspace\ec\ec\manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager
utility.execute()
File "C:\Python26\lib\site-packages\django\core\management\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 219, in execute
self.validate()
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "C:\Python26\lib\site-packages\django\core\management\validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 146, in get_app_errors
self._populate()
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 61, in _populate
self.load_app(app_name, True)
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 83, in load_app
if not module_has_submodule(app_module, 'models'):
File "C:\Python26\lib\site-packages\django\utils\module_loading.py", line 17, in module_has_submodule
for entry in package.__path__: # No __path__, then not a package.
AttributeError: 'module' object has no attribute '
path'
BeautifulSoup is not a Django-app. Its a python package/module. You don't have to add to INSTALLED_APPS. It just need to be available in your PYTHONPATH to use it.
Your traceback doesn't give clue what is actually wrong with your Django project.
The only time you ever need to do a syncdb is when you have to do something to the db. BeautifulSoup does not need to use the db at any point and does not need to be an installed app
When I am trying to validate, I am getting this error.
python manage.py validate
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/validate.py", line 9, in handle_noargs
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 146, in get_app_errors
self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 61, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/google/Myfiles/cheeserater/../cheeserater/packages/models.py", line 4, in <module>
class Package(models.Model):
File "/usr/local/google/Myfiles/cheeserater/../cheeserater/packages/models.py", line 11, in Package
categories = models.ManytoManyField(Category,related_name="packages")
AttributeError: 'module' object has no attribute 'ManytoManyField'
You have a typo:
categories = models.ManyToManyField
You have a typo in ManytoManyField,
It should be ManyToManyField.