content of script.py is
{{{
#!python
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
import django
django.setup()
from django.apps import apps
for app in apps.get_app_configs():
print app.path
}}}
If I run `python script.py`, output will be
{{{
$ python script.py
....
/<project_path>/root/app1
/<project_path>/root/app2
}}}
If I run `ipython script.py`, output is
{{{
$ ipython script.py
....
app1
app2
}}}
Ipython inserts !'' as the first entry in sys.path which results in path
for project apps being relative path.
This in turn is making the output of
`django.template.utils.get_app_template_dirs` inconsistent.
I faced this issue with python 2.7.11+
This is not an issue with python 2.7.12. I think because of
[https://bugs.python.org/issue1739468 Patch #1739468]
--
Ticket URL: <https://code.djangoproject.com/ticket/27230>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
As per our [https://docs.djangoproject.com/en/dev/faq/install/#what-
python-version-can-i-use-with-django support policy], "For each version of
Python, only the latest micro release (A.B.C) is officially supported." So
perhaps we can close the issue as wontfix unless there's some other
argument for making the change?
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:1>
Comment (by vinayinvicible):
Even with 2.7.12, `AppConfig.path` will return relative path if I do
`sys.path.insert(0, '')` inside script.py before `django.setup()`
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:2>
* type: Uncategorized => Bug
* component: Uncategorized => Core (Other)
Comment:
Not sure about this right now, but tests aren't passing with the
[https://github.com/django/django/pull/7251 PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:3>
Comment (by aaugustin):
1. I'm wary of making this backwards-incompatible change.
2. I think you're hitting this issue because in one case an absolute
import is performed and in the other an implicit relative import. IIRC,
Python 3 no longer supports the latter, so the resolution is essentially
"fixed in Python 3"...
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:4>
Comment (by vinayinvicible):
I understand this wouldn't be an issue with python 3.
Shouldn't django handle this atleast until it supports python 2.
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:5>
Comment (by aaugustin):
Well, given that the issue doesn't exist in Python 3, is fixed in Django
2.7.12+, and that we're dropping support for Python 2 in six months:
https://www.djangoproject.com/weblog/2015/jun/25/roadmap/:
> Django 1.11 is likely to be the last version to support Python 2.7 as it
will be supported until the end of Python 2 upstream support in 2020.
absent other reasons, it doesn't seem reasonable to me to change the
return value of AppConfig.path from a relative to an absolute path, which
could cause issues with projects that use this value.
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:6>
* status: new => closed
* resolution: => wontfix
--
Ticket URL: <https://code.djangoproject.com/ticket/27230#comment:7>