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

Why split DJANGO_SETTINGS_MODULE in function find_pos()? #267

Open
Dongbox opened this issue May 21, 2022 · 1 comment
Open

Why split DJANGO_SETTINGS_MODULE in function find_pos()? #267

Dongbox opened this issue May 21, 2022 · 1 comment

Comments

@Dongbox
Copy link

Dongbox commented May 21, 2022

  • Which version of Django are you using?: 3.2
  • Which version of django-rosetta are you using?: latest
  • Have you looked trough recent issues and checked this isn't a duplicate? Y

This is the original code in poutil.py, and when my structure of settings is settings/*, errors will be like TypeError: expected str, bytes or os.PathLike object, not NoneType, since "settings.*".split('.') happended and settings here is a directory, which no __file__ was included.

# rosetta/poutil.py
def find_pos(lang, project_apps=True, django_apps=False, third_party_apps=False):
    # project/locale
    if settings.SETTINGS_MODULE:
        parts = settings.SETTINGS_MODULE.split('.')
    else:
        # if settings.SETTINGS_MODULE is None, we are probably in "test" mode
        # and override_settings() was used
        # see: https://code.djangoproject.com/ticket/25911
        parts = os.environ.get(ENVIRONMENT_VARIABLE).split('.')
    project = __import__(parts[0], {}, {}, [])
    # TODO: update below
    project = __import__("settings.dev")

So what should I do if my settings structure is settings/*?

@iStorry
Copy link

iStorry commented Oct 14, 2022

You can try this
sed -i '' 's/parts\[0\]/parts[2]/g' venv/lib/python3.10/site-packages/rosetta/poutil.py

if your project structure is like this

  • basedir
    • src
      • project
        • settings.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants