Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following contributing guide, migration step failing #1455

Open
bigbuckalex opened this issue Oct 26, 2022 · 7 comments
Open

Following contributing guide, migration step failing #1455

bigbuckalex opened this issue Oct 26, 2022 · 7 comments
Assignees
Labels
triage Issues that have not been categorized or prioritized

Comments

@bigbuckalex
Copy link

Description

I am following the contributing guide and I am getting this error message on the "Run migrations" step:

AttributeError: <asgiref.local.Local object at 0x7fd729a86e60> object has no attribute 'default'

What should have happened?

No response

What browser(s) are you seeing the problem on?

Not applicable

Further details

Full error message:

Traceback (most recent call last):
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/utils/connection.py", line 58, in __getitem__
    return getattr(self._connections, alias)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/asgiref/local.py", line 105, in __getattr__
    raise AttributeError(f"{self!r} object has no attribute {key!r}")
AttributeError: <asgiref.local.Local object at 0x7fd729a86e60> object has no attribute 'default'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alex/GitHub/OpenCiviWiki/project/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/core/management/__init__.py", line 420, in execute
    django.setup()
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/apps/registry.py", line 116, in populate
    app_config.import_models()
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/apps/config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/db/models/base.py", line 141, in __new__
    new_class.add_to_class("_meta", Options(meta, app_label))
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/db/models/base.py", line 369, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/db/models/options.py", line 231, in contribute_to_class
    self.db_table, connection.ops.max_name_length()
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/utils/connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/utils/connection.py", line 60, in __getitem__
    if alias not in self.settings:
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/utils/functional.py", line 57, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/utils/connection.py", line 45, in settings
    self._settings = self.configure_settings(self._settings)
  File "/home/alex/.cache/pypoetry/virtualenvs/openciviwiki-vDri1UYP-py3.10/lib/python3.10/site-packages/django/db/utils.py", line 160, in configure_settings
    conn.setdefault("ATOMIC_REQUESTS", False)
AttributeError: 'str' object has no attribute 'setdefault'
@bigbuckalex bigbuckalex added the triage Issues that have not been categorized or prioritized label Oct 26, 2022
@brylie
Copy link
Member

brylie commented Oct 27, 2022

There was an error in the installation guide that may have led to the above error.

Make sure you run poetry install from the repository root directory before changing the guide into the project/ subdirectory.

The migrations worked for me when I attempted them just now.

@brylie brylie self-assigned this Oct 27, 2022
@bigbuckalex
Copy link
Author

I've tried deleting and re-cloning the repo and I still get the same error. Here is a video of the process, am I doing anything wrong?

open-civi-wiki.mp4

@brylie
Copy link
Member

brylie commented Oct 28, 2022

Can you upload a video where it creates the initial Poetry virtual environment?

@bigbuckalex
Copy link
Author

Is this what you mean? I deleted the poetry environment so poetry install would create a new virtual environment.

open-civi-wiki-2.mp4

@brylie
Copy link
Member

brylie commented Oct 30, 2022

@gorkemarslan are you able to spot anything that might be causing this bug?

@gorkemarslan
Copy link
Collaborator

@bigbuckalex, what operating system are you using?

As far as I understand, the Django framework cannot connect your local database because it cannot validate the database configs.

Can you try to replace the database configs in your settings.py file

# Use DATABASE_URL in production
DATABASE_URL = os.getenv("DATABASE_URL")
if DATABASE_URL is not None:
DATABASES = {"default": DATABASE_URL}
else:
# Default to sqlite for simplicity in development
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR + "/" + "db.sqlite3",
}
}

with the default one:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

@bigbuckalex
Copy link
Author

@gorkemarslan I am using Pop!_OS 22.04

Replacing the database configs allowed me to run the migrations. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Issues that have not been categorized or prioritized
Projects
None yet
Development

No branches or pull requests

3 participants