title: Django ViewDoesNotExist when it does
body: <p>I have a django app running off a Twisted service that can't resolve the views of some of the applets. </p>
  
  <p>When I run the app on the Django dev server it loads fine, but when I run it off Twisted I get the error <code>Could not import apps.ai_stats.views. Error was: No module named aidb</code> when I navigate to those applets in the browser, the only issue is that the aidb.py file is absolutely located in these applet directories. My structure is as follows.</p>
  
  <pre><code>apps/
      ai_stats/
          __init__.py
          ai2.py
          aidb.py
          models.py
          urls.py
          views.py
      __init__.py
      manage.py
      settings.py
      urls.py
      views.py
  </code></pre>
  
  <p>I can't figure out why it won't load this particular module. I have a bunch of different applets in the one app and some work with this and others don't. If there is any other information needed please let me know.</p>
  
  <p>Here is my views.py file:
  It calls another file named ai2.py, which then calls aidb.py.</p>
  
  <pre><code>from django.shortcuts import render_to_response
  from django.http import HttpResponseRedirect
  from django.core.urlresolvers import reverse
  
  import ai2
  
  
  def index(request):
      # ai2.refresh_cache()
      return render_to_response('ai_stats/index.html', locals())
      # return HttpResponseRedirect(reverse('apps.ai_stats.views.dashboard', kwargs={'env':ai2.PROD}))
  
  
  def dashboard(request, env):
      ai2.refresh_cache()
      # env = ai2.PROD
      mf_error, mf_data, _ = ai2.AIStats().data_for_chart('most_failures', env=env)
      mc_error, mc_data, _ = ai2.AIStats().data_for_chart('most_calls', env=env)
      wp_error, wp_data, _ = ai2.AIStats().data_for_chart('worst_performing', env=env)
      error = (mf_error or '') + (mc_error or '') + (wp_error or '')
      cache_timestamp = ai2.data_cache['timestamp']
      return render_to_response('ai_stats/dashboard.html', locals())
  
  
  def drill(request, env, chart):
      # env = ai2.PROD
      row_limit = int(request.GET.get('limit', 100))
      error, data, _ = ai2.AIStats().data_for_chart(chart, env=env, limit=row_limit)
      cache_timestamp = ai2.data_cache['timestamp']
      return render_to_response('ai_stats/drill_%s.html' % chart, locals())
  
  
  def dash_data(request, env, chart):
      # env = ai2.PROD
      error, data, chart_type = ai2.AIStats().data_for_chart(chart, env=env, params=request.GET)
      r = render_to_response('ai_stats/%s.xml' % chart, locals())
      if chart_type == ai2.GRAPH_CHART:
          r['Content-Type'] = 'text/xml'
      return r
  
  
  def pop(request, env, chart):
      pop_template = 'pop_mtd'
      if chart == 'all_mtd':
          pop_template = 'pop_all'
      ops_chart = '%s_ops' % chart
      return render_to_response('ai_stats/' + pop_template + '.html', locals())
  </code></pre>
  
  <p>Here is the full traceback:</p>
  
  <pre><code>Environment:
  
  
      Request Method: GET
  Request URL: https://0.0.0.0/ai_stats/
  
  Django Version: 1.3.1
  Python Version: 2.7.5
  Installed Applications:
  ['django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.admin',
   'django.contrib.admindocs',
   'django.contrib.staticfiles',
   'apps.minisar',
   'apps.mock',
   'apps.actional',
   'apps.ai_stats',
   'apps.health',
   'apps.soap',
   'apps.directentry',
   'apps.toys',
   'apps.solutions']
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware')
  
  
  Traceback:
  File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    101.                             request.path_info)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
    252.                     sub_match = pattern.resolve(new_path)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
    252.                     sub_match = pattern.resolve(new_path)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
    158.             return ResolverMatch(self.callback, args, kwargs, self.name)
  File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py" in _get_callback
    167.             raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))
  
  Exception Type: ViewDoesNotExist at /ai_stats/
  Exception Value: Could not import apps.ai_stats.views. Error was: No module named aidb
  </code></pre>