title: Broke my Django app - a path problem?
body: <p>The symptoms:</p>
  
  <blockquote>
    <p>Could not import tinycomm.views. Error was: No module named models</p>
  </blockquote>
  
  <p>The line of code:</p>
  
  <pre><code> from tinycomm.models import *
  </code></pre>
  
  <p>Project structure:</p>
  
  <pre><code>/tinycomms
    /tinycomm
      models.py
      views.py
      etc.
    /other apps.
  </code></pre>
  
  <p>On <a href="http://en.wikipedia.org/wiki/Mac_OS_X" rel="nofollow noreferrer">Mac OS X</a> in development I can fix this by putting tinycomms.tinycomm.models and then another similar error pops up elsewhere.  I got development working by changing about 10 paths to models and forms in the app (many more remained just as tinycomm.module) by changing the path every time it fell over.</p>
  
  <p>I uploaded to an Ubuntu production server and experienced the same problem, only the full name does not solve the problem.</p>
  
  <p>This app has been working fine for months and the only major change that I can think of was to install <a href="http://en.wikipedia.org/wiki/Aptana#Aptana_Jaxer" rel="nofollow noreferrer">Aptana Jaxer</a> on Mac OS X, but as the problem also exists in production I am not sure that is the problem.</p>
  
  <p>Other biggish change was to change the app folder name from 'web' to 'tinycomm' but with the full path fixes in development, it was working, so I am not sure that is the cause either.</p>
  
  <p>Here is a list of the things I have tried:</p>
  
  <ol>
  <li>All the files it says it can't find are definitely where they should be</li>
  <li><strong>init</strong>.py everywhere it should be</li>
  <li>paths to everywhere added /home/project_dir, /home/project_dir/tinycomms, /home/project_dir/tinycomms/tinycomm</li>
  <li>tried removing all these paths as well</li>
  <li>Tried taking out all the apps one by one - the modules that it complained about changed, but the basic <code>No module named x</code> remained the same.</li>
  <li>removed all the middleware etc.</li>
  <li>Upgraded to Django 1.2</li>
  </ol>
  
  <p>Here is the full output:</p>
  
  <pre><code>Environment:
  
      Request Method: GET
      Request URL: http://127.0.0.1:8004/
      Django Version: 1.2 alpha 1
      Python Version: 2.5.2
      Installed Applications:
      ['django.contrib.auth',
       'django.contrib.contenttypes',
       'django.contrib.sessions',
       'django.contrib.sites',
       'django.contrib.admin',
       'tinycomms_tagging',
       'tinycomm']
      Installed Middleware:
      ('django.middleware.common.CommonMiddleware',
       'django.contrib.sessions.middleware.SessionMiddleware',
       'django.contrib.auth.middleware.AuthenticationMiddleware',
       'django_authopenid.middleware.OpenIDMiddleware')
  
  
  Traceback:
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/base.py" in get_response
        90.                         request.path_info)
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
        222.                     sub_match = pattern.resolve(new_path)
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in resolve
        129.             return self.callback, args, kwargs
      File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/urlresolvers.py" in _get_callback
        138.             raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e))
  
  Exception Type: ViewDoesNotExist at /
  Exception Value: Could not import tinycomm.views. Error was: No module named models
  </code></pre>
  
  <p>Any suggestions of what to try next gratefully received!</p>
  
  <p>Contents of tinycomm/<strong>init</strong>.py:</p>
  
  <pre><code>from django.utils.translation import ugettext as _
  
  from tinycomms_tagging.managers import ModelTaggedItemManager, TagDescriptor
  
  VERSION = (0, 3, 'pre')
  
  class AlreadyRegistered(Exception):
      """
      An attempt was made to register a model more than once.
      """
      pass
  
  registry = []
  
  def register(model, tag_descriptor_attr='tags',
               tagged_item_manager_attr='tagged'):
      """
      Sets the given model class up for working with tags.
      """
      if model in registry:
          raise AlreadyRegistered(
              _('The model %s has already been registered.') % model.__name__)
      registry.append(model)
  
      # Add tag descriptor
      setattr(model, tag_descriptor_attr, TagDescriptor())
  
      # Add custom manager
      ModelTaggedItemManager().contribute_to_class(model,
                                                   tagged_item_manager_attr)
  </code></pre>