没有名为app的模块

没有名为app的模块

本文介绍了Django - 没有名为app的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试用django编写的应用程序,但是它根本不工作。我一直在工作一段时间 - 它正在开发服务器上完美。但是我无法投入生产env(apahce)。

I have been trying to get an application written in django working - but it is not working at all. I have been working on for some time too - and it is working on dev-server perfectly. But I am unable to put in the production env (apahce).

我的项目名称是apstat,应用程序名称是基本的。

My project name is apstat and the app name is basic.

我尝试访问它如下

但它显示以下错误:

MOD_PYTHON ERROR

ProcessId:      6002
Interpreter:    'domU-12-31-39-06-DD-F4.compute-1.internal'

ServerName:     'domU-12-31-39-06-DD-F4.compute-1.internal'
DocumentRoot:   '/home/ubuntu/server/'

URI:            '/apstat/'
Location:       '/apstat'
Directory:      None
Filename:       '/home/ubuntu/server/apstat/'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.6/dist-packages/mod_python/importer.py", line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py", line 201, in __call__
    response = self.get_response(request)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 134, in get_response
    return self.handle_uncaught_exception(request, resolver, exc_info)

  File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 154, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)

  File "/usr/lib/pymodules/python2.6/django/views/debug.py", line 40, in technical_500_response
    html = reporter.get_traceback_html()

  File "/usr/lib/pymodules/python2.6/django/views/debug.py", line 114, in get_traceback_html
    return t.render(c)

  File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 178, in render
    return self.nodelist.render(context)

  File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 779, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 81, in render_node
    raise wrapped

TemplateSyntaxError: Caught an exception while rendering: No module named basic

Original Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 87, in render
    output = force_unicode(self.filter_expression.resolve(context))
  File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 572, in resolve
    new_obj = func(obj, *arg_vals)
  File "/usr/lib/pymodules/python2.6/django/template/defaultfilters.py", line 687, in date
    return format(value, arg)
  File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 269, in format
    return df.format(format_string)
  File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 30, in format
    pieces.append(force_unicode(getattr(self, piece)()))
  File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 175, in r
    return self.format('D, j M Y H:i:s O')
  File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 30, in format
    pieces.append(force_unicode(getattr(self, piece)()))
  File "/usr/lib/pymodules/python2.6/django/utils/encoding.py", line 71, in force_unicode
    s = unicode(s)
  File "/usr/lib/pymodules/python2.6/django/utils/functional.py", line 201, in __unicode_cast
    return self.__func(*self.__args, **self.__kw)
  File "/usr/lib/pymodules/python2.6/django/utils/translation/__init__.py", line 62, in ugettext
    return real_ugettext(message)
  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 286, in ugettext
    return do_translate(message, 'ugettext')
  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 276, in do_translate
    _default = translation(settings.LANGUAGE_CODE)
  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 194, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 180, in _fetch
    app = import_module(appname)
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named basic

我的settings.py如下:

My settings.py is as follows:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'apstat.basic',
    'django.contrib.admin',
)

如果我删除apstat.basic,它会经历,但这不是一个解决方案。我在apache中做的是什么?

If I remove the apstat.basic, it goes through, but that is not a solution. Is it something I am doing in apache?

我的apache - 设置是 -

My apache - settings are -

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/ubuntu/server/
        <Directory />
                Options None
                AllowOverride None
        </Directory>

        <Directory /home/ubuntu/server/apstat>
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        <Location "/apstat">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE apstat.settings
                PythonOption django.root /home/ubuntu/server/
                PythonDebug On
                PythonPath "['/home/ubuntu/server/'] + sys.path"
        </Location>

</VirtualHost>

我现在坐了一天以上。如果有人可以帮助我,这将是非常好的。

I have now sat for more than a day on this. If someone can help me out, it would be very nice.

推荐答案

你的基本是否有 __ init__。 py

这篇关于Django - 没有名为app的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 17:59