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

Remove model imports in any utils/ modules #443

Open
AlanCoding opened this issue Jun 7, 2024 · 3 comments
Open

Remove model imports in any utils/ modules #443

AlanCoding opened this issue Jun 7, 2024 · 3 comments
Labels
app:lib code quality This item relates to code quality good first issue Good for newcomers help wanted Extra attention is needed ready to work Item is ready to be worked on

Comments

@AlanCoding
Copy link
Member

To prevent circular imports, we want ansible_base/utils imports to always be "safe" to import inside of Django apps.

Right now this doesn't work due to a stray import of AbstractUser which needs apps to be loaded before importing (or will throw an error).

This can be done by moving these imports in-line, or more elegantly, but further code refactoring.

@AlanCoding AlanCoding added good first issue Good for newcomers help wanted Extra attention is needed ready to work Item is ready to be worked on code quality This item relates to code quality app:lib labels Jun 7, 2024
darshannv added a commit to darshannv/django-ansible-base that referenced this issue Jun 7, 2024
@Kuppjaerk
Copy link

Hi!

Is this issue still awaiting resolution? If so, I'd like to take a look at it. I'm a uni student who's currently taking an open source course, which includes making contributions.

@AlanCoding
Copy link
Member Author

Yes, still unresolved. The import in question is:

from django.contrib.auth.models import AbstractUser

In many cases, Model, would be an acceptable replacement, which does not require apps to be loaded to be able to import.

A solution can be verified by using the python3 terminal, without doing any other setup before that.

>>> from ansible_base.lib.utils import *
>>> from ansible_base.lib.utils.models import *

The first line is successful, but the 2nd line errors. Make that not error, and this is solved.

@Kuppjaerk
Copy link

Alright, I'll start working on this then, thanks for the quick reply! I'm quite new to contributing to ansible, is there a certain Matrix room I could ask questions regarding django-ansible-base?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:lib code quality This item relates to code quality good first issue Good for newcomers help wanted Extra attention is needed ready to work Item is ready to be worked on
Projects
None yet
Development

No branches or pull requests

2 participants