【问题标题】:moving app to new server将应用程序移动到新服务器
【发布时间】:2011-04-07 16:30:05
【问题描述】:

我必须将应用程序从一台服务器移动到另一台服务器。它也是debian,所以我安装了旧服务器上安装的所有python包,然后将文件移动到相同的目录(我希望:D)

当我尝试检查它是否有效时,我收到这样的错误:

URI:            '/'
Location:       '/'
Directory:      None
Filename:       '/var/www/'
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 141, in get_response
    return self.handle_uncaught_exception(request, resolver, sys.exc_info())

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

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

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

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

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

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

  File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 72, in render_node
    result = node.render(context)

  File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 89, in render
    output = self.filter_expression.resolve(context)

  File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 579, in resolve
    new_obj = func(obj, *arg_vals)

  File "/usr/lib/pymodules/python2.6/django/template/defaultfilters.py", line 697, in date
    return format(value, arg)

  File "/usr/lib/pymodules/python2.6/django/utils/dateformat.py", line 281, 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 187, 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 66, in force_unicode
    s = unicode(s)

  File "/usr/lib/pymodules/python2.6/django/utils/functional.py", line 206, in __unicode_cast
    return self.__func(*self.__args, **self.__kw)

  File "/usr/lib/pymodules/python2.6/django/utils/translation/__init__.py", line 55, in ugettext
    return real_ugettext(message)

  File "/usr/lib/pymodules/python2.6/django/utils/functional.py", line 55, in _curried
    return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))

  File "/usr/lib/pymodules/python2.6/django/utils/translation/__init__.py", line 36, in delayed_loader
    return getattr(trans, real_name)(*args, **kwargs)

  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 276, in ugettext
    return do_translate(message, 'ugettext')

  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 266, in do_translate
    _default = translation(settings.LANGUAGE_CODE)

  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 176, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)

  File "/usr/lib/pymodules/python2.6/django/utils/translation/trans_real.py", line 159, in _fetch
    app = import_module(appname)

  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)

  File "/usr/lib/pymodules/python2.6/django/contrib/admin/__init__.py", line 1, in <module>
    from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME

  File "/usr/lib/pymodules/python2.6/django/contrib/admin/helpers.py", line 1, in <module>
    from django import forms

  File "/usr/lib/pymodules/python2.6/django/forms/__init__.py", line 17, in <module>
    from models import *

  File "/usr/lib/pymodules/python2.6/django/forms/models.py", line 6, in <module>
    from django.db import connections

  File "/usr/lib/pymodules/python2.6/django/db/__init__.py", line 77, in <module>
    connection = connections[DEFAULT_DB_ALIAS]

  File "/usr/lib/pymodules/python2.6/django/db/utils.py", line 91, in __getitem__
    backend = load_backend(db['ENGINE'])

  File "/usr/lib/pymodules/python2.6/django/db/utils.py", line 49, in load_backend
    raise ImproperlyConfigured(error_msg)

TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql' isn't an available database backend. 
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name utils

我不知道我忘了安装什么。不幸的是 - 在移动之前无法检查它是否有效(旧服务器已关闭)。为了更好地理解 - 很久以前的应用程序可以正常工作。比有一些 apt-get dist-upgrade,这可能会导致这个错误。今天我想使用这个应用程序,我看到服务器肯定已经关闭,所以我把所有东西都搬到了新的(很高兴,那个硬盘仍然可以工作)。

【问题讨论】:

  • "TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql' 不是可用的数据库后端。"这似乎很清楚。你安装了 postgres 了吗?
  • 您是否安装了postgresqlpostgresql.org
  • @Blender - 当然是的 - 我可以使用在 settings.py 中定义的相同主机和端口远程登录到 postgres

标签: django apache2 debian


【解决方案1】:

您是否安装了postgresql?是数据库服务器,出现这个错误:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql' isn't an available database backend.

说它不可用。

【讨论】:

  • 也可以安装,只是不运行。
  • @Neoman - 当然是的 - 我可以使用在 settings.py 中定义的相同主机和端口远程登录到 postgres
【解决方案2】:

阅读源代码!

来自 django/db/backends/postgresql/base.py

""" 用于 Django 的 PostgreSQL 数据库后端。

需要 psycopg 1:http://initd.org/projects/psycopg1 """

您可能缺少 psycopg - python 的(旧)postgres 连接器。

我建议安装 psycopg2 并使用 postgresql_psycopg2 后端。

【讨论】:

    猜你喜欢
    • 2013-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-20
    • 2013-04-26
    相关资源
    最近更新 更多