Opened 6 years ago

Closed 2 years ago

#12231 closed Bug (worksforme)

The project path is incorrectly build, it wipe the namespace

Reported by: mleduc Owned by: nobody
Component: Core (Other) Version: master
Severity: Normal Keywords: package
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Alex)

If by example your django is in an egg like

my.site.project

If you call the django core execution manager with:

mod = __import__('my.site.project')
django.core.management.execute_manager(mod)

Your project will not be found cause the django core is declaring the main DJANGO_SETTINGS_MODULE with:

django.core.management.init:

...
project_directory, settings_filename = os.path.split(p)
if project_directory == os.curdir or not project_directory:
   project_directory = os.getcwd()
project_name = os.path.basename(project_directory)
...
os.environ['DJANGO_SETTINGS_MODULE = '%s.%s' % (project_name, settings_name)
...

The project_name variable represent only the first level of the project egg. It could not work with a multilevel package and we now have to use the variable 'original_settings_path' which is just optional.

The solution maybe to use the special package variable of the settings_mod module.

I attach a patch with this ticket whick correct this problem.

Attachments (1)

management.patch (554 bytes) - added by mleduc 6 years ago.
django.core.management.init.py patch

Download all attachments as: .zip

Change History (8)

Changed 6 years ago by mleduc

django.core.management.init.py patch

comment:1 Changed 6 years ago by Alex

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please use preview.

comment:2 Changed 5 years ago by russellm

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by ubernostrum

  • milestone 1.2 deleted

1.2 is feature-frozen, moving this feature request off the milestone.

(and egg support is most definitely a feature request)

comment:4 Changed 4 years ago by mattmcc

  • Severity set to Normal
  • Type set to Bug

comment:5 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:7 Changed 2 years ago by claudep

  • Resolution set to worksforme
  • Status changed from new to closed

Most of this code is now obsolete. Reopen with current code references if still valid.

Note: See TracTickets for help on using tickets.
Back to Top