如何将 Django 从 dev 降级到 1.1

发布于 2024-08-11 06:20:50 字数 958 浏览 3 评论 0原文

我正在运行 Django 的开发版本,由于对 CSRF 进行了更改,文件浏览器应用程序似乎与 trunk 不兼容。如何降级到正式版本(1.1)?

我正在共享主机上工作,当前运行 Django 的方式如下:

~/local/lib/python2.6/site-packages/ contains /django/ 以及其他几个文件夹(每个应用程序一个)。

~/local/lib/python2.6/site-packages/ 位于 python 路径上。

/site-packages/ 中,还有一个指向 /projectname/ 的符号链接,其中包含项目文件(manage.py、settings.py 等)。

我正在使用 FastCGI,因此在 /public_html/ 中我有一个 dispatch.fcgi 用于调用 django.core.servers.fastcgi.runfastcgi >。 .htaccess 文件用于将所有请求重定向到dispatch.fcgi,以便Django 可以处理它们。

我尝试删除(移出 python 路径)/django/,然后下载 Django 的发行版并将其放在之前的 /django/ 文件夹所在的位置。这产生了以下错误:

没有名为 CSRF 的模块。

我从 /trunk/ 下载了 middleware/csrf.py ,它清除了第一个错误,但随后产生了其他错误。

我应该如何降级到 1.1?从头开始并不是不可能的,但如果可能的话,我显然宁愿避免这种情况。

I am running the development version of Django and it appears that the filebrowser app is not compatible with trunk because of changes made to CSRF. How do I downgrade to the official release (1.1)?

I am working on a shared host and the way that I am curently running Django is as follows:

~/local/lib/python2.6/site-packages/ contains /django/ as well as several other folders (one for each app).

~/local/lib/python2.6/site-packages/ is on the python path.

Within /site-packages/ there is also a symlink to /projectname/ that contains the project files (manage.py, settings.py, etc.).

I am using FastCGI and therefore in /public_html/ I have a dispatch.fcgi that is used to call django.core.servers.fastcgi.runfastcgi. A .htaccess file is used to redirect all requests to dispatch.fcgi so that Django can handle them.

I tried removing (moving out of the python path) /django/ and then downloading the release version of Django and putting it where the previous /django/ folder was. This produced the following error:

No module named CSRF.

I downloaded middleware/csrf.py from /trunk/ which cleared up the first error but then produced other errors.

How should I go about downgrading to 1.1? Starting from scratch isn't out of the question but I'd obviously rather avoid this if possible.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风轻花落早 2024-08-18 06:20:50

/site-packages/ 目录中查找 Django-1.other_stuff.egg-info 文件并删除找到的所有文件,然后重试(1.1 的代码仍然存在)如果这不起作用,只需从最新版本的 tarball (python setup.py install) 重新运行 Django 安装程序即可

。 ,如果您安装了 pip 您可能只需执行 pip install -U Django== 1.1.1 终端中的

D 请注意这些 Egg-info 文件中的 Django 和 pip 命令。

Look in your /site-packages/ directory for Django-1.other_stuff.egg-info files and delete any you find, then try again (with the code for 1.1 still in the site-packages/django/ directory. If this doesn't work, just re-run the Django installer from the latest release tarball (python setup.py install) and you should be good.

Alternatively, if you have pip installed you can probably just do pip install -U Django==1.1.1 in the terminal.

Note the capital D in Django in those egg-info files and the pip command.

遇见了你 2024-08-18 06:20:50

我已经成功降级,这实际上是一个非常简单的过程。希望这能帮助那些忽视我所做的事情的人。

1.1.1 中 django-admin.py 的 startproject 命令创建的 settings.py 文件与当前开发版本略有不同。

当前开发版本中的 startproject 有一个额外的中间件类 - csrf。 1.1.1 中的 startproject 命令创建相同的 settings.py,但删除了第三个类。注释掉或删除这一行可以使 Django 正常工作。

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware', #additional middleware class
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)

I have managed to successfully downgrade and it is actually an extremely easy process. Hopefully this will help people out who overlook what I did.

The startproject command of django-admin.py in 1.1.1 creates a slightly different settings.py file than the current development release.

startproject in with the current dev release has an extra middleware class - csrf. The startproject command in 1.1.1 creates the same settings.py but with the third class removed. Commenting out or removing this line gets Django working properly.

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware', #additional middleware class
    'django.contrib.auth.middleware.AuthenticationMiddleware',
)
╭ゆ眷念 2024-08-18 06:20:50

你可以在你的用户空间中安装你想要的版本的django,比如说在/home/me/lib/中,

然后如果你在你的mysite.wsgi中使用mod_wsgi有一行:

sys.path.insert(0,'/home/me/lib/Django-1.1')

这将确保django从你的安装中加载,不是服务器范围的。

您还需要调整 shell 环境路径变量,以便启动正确的 django-admin.py 或直接运行

python /home/me/lib/Django-1.1/django/bin/django-admin.py ...

you can just install django of the version you want in you user space, say in /home/me/lib/

then if you are using mod_wsgi in your mysite.wsgi have a line:

sys.path.insert(0,'/home/me/lib/Django-1.1')

this will insure that django is loaded from your installation, not the server-wide.

you'll also need to adjust your shell environment path variable so that correct django-admin.py is launched or just run directly

python /home/me/lib/Django-1.1/django/bin/django-admin.py ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文