title: Python/Django is importing the wrong module (relative when it should be absolute)
body: <p>I'm using Django 1.2 pre-alpha and Python 2.4. Yeah, I know, but I'm stuck with it. We can't upgrade at the moment and I doubt that's the answer anyway.</p>
  
  <p>I've got two template tag libraries, <code>foo</code> and <code>bar</code>. However, <code>foo</code> is also the name of a top-level package, and it happens to be the package of <code>bar</code>:</p>
  
  <pre><code>foo-1.2.3/
    foo/
      conf/
        settings.py
      templatetags/
        bar.py
  
  bar-4.5/
    somepackage/
      templatetags/
        foo.py
  </code></pre>
  
  <p>The tag library <code>bar.py</code> contains a line like this:</p>
  
  <pre><code>from foo.conf import settings
  </code></pre>
  
  <p>...and you would expect it to load <code>foo-1.2.3/foo/conf/settings.py</code>.</p>
  
  <p>But no:</p>
  
  <blockquote>
    <p>TemplateSyntaxError: 'bar' is not a valid tag library: Could not load template library from django.templatetags.bar, No module named conf</p>
  </blockquote>
  
  <p>Unfortunately, Django performs <a href="http://www.b-list.org/weblog/2007/dec/04/magic-tags/" rel="nofollow">a little magic</a> and binds all template tag libraries to <code>django.templatetags.*</code>. Thus, <code>bar</code> is being imported as <code>django.templatetags.bar</code>, and when it calls <code>from foo.conf import settings</code> it ends up importing <code>bar-4.5/somepackage/templatetags/foo.py</code>. Ugh!</p>
  
  <p><strong>Do you have any ideas how to fix this?</strong></p>
  
  <p>I've set a breakpoint right before the import, and I've confirmed that <code>foo-1.2.3</code> is at the beginning of <code>sys.path</code>, but the <code>import</code> keyword still finds the wrong <code>foo</code>.</p>
  
  <p>If it helps, note that I can modify the <code>foo-1.2.3</code> package (because it's been checked in locally and is being phased out), but I refuse to modify the <code>bar-4.5</code> package (because it's an open-source package and has been installed system-wide).</p>