Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get my Django manage.py working properly when the files are accessed through a symlink?
    primarykey
    data
    text
    <p><strong>Problem</strong></p> <p>When trying to run one of my custom Django management commands (<code>send_notify_emails</code>), I get the following error:</p> <pre><code>$ python web_apps/manage.py send_notify_emails Traceback (most recent call last): File "web_apps/manage.py", line 11, in &lt;module&gt; execute_manager(settings) File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 436, in execute_manager setup_environ(settings_mod) File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 419, in setup_environ project_module = import_module(project_name) File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) ImportError: No module named my_django_app-1.0 </code></pre> <p><strong>Background</strong></p> <p>I have a Django site with two apps in it. The path to the site directory (which includes the app module directories, as well as settings.py, urls.py and manage.py) is <code>/srv/web_apps</code>. This is a symbolic link to <code>/usr/share/my_django_app-1.0</code>, which is an <code>svn export</code> of a production release tag. This way I can change my app version over by just moving the symbolic link to the path for the new production version, and easily change back to an earlier release if I need to.</p> <p>My <code>django.wsgi</code> file adds <code>/srv</code> and <code>/srv/web_apps</code> to the Python path so that <code>mod_wsgi</code> can find my settings and url files, as well as the app modules.</p> <p>The ONLY place that <code>my_django_app-1.0</code> appears is the directory path, it is not anywhere in my <code>settings.py</code> or otherwise, so Django must be getting the module name from the path.</p> <p>What <em>seems</em> to be happening is Django is resolving the package name for my app by following the symbolic link and using the name of the target folder, instead of the symbolic link itself. When I run <code>manage.py</code>, Django tries to import <code>my_django_app-1.0</code> when it should be importing <code>web_apps</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload