Django python 无法将管理默认设计设置为我的界面

发布于 2024-11-02 11:40:47 字数 1791 浏览 1 评论 0原文

我已经尝试了 Django 几天,并且正在尝试使用 apache 建立一个生产项目。 的官方教程进行操作

我已按照http://docs.djangoproject.com/en/ 1.3/intro/tutorial01/

在开发服务器上一切都工作得很好,但在 apache 上,我失去了所有管理风格。

我已经阅读过有关此问题的类似帖子,但从现在起没有任何成功。

Django admin 没有样式 Django:丑陋的管理界面

这可能是一个权限问题,但我已经复制了媒体文件存储在

/usr/share/pyshared/django/contrib/admin/media/

到我服务器的 /data

/data/mysite/ 下 /数据/媒体/ /data/templates/

的不同值

我已经尝试了 /data/mysite/settings.py /media/、/data/media/

,以及 apache 配置中的 Alias 项目。

这是我的 apache 配置 ` ServerAdmin webmaster@localhost

DocumentRoot /data/sites/accounts/

Alias /media/ /usr/share/pyshared/django/contrib/admin/media/

<Directory />
    Options None
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location />
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined

`

我的直觉认为这是一个正确的问题,但是 /data/media/ 和 /data/templates 具有相同的权限/所有者,我可以毫无问题地修改任何模板,但仍然没有管理员样式。 apache 提供的每个文件都属于 root:www-data,文件属于 750,目录属于 710。

我真的感谢你们任何人提供任何帮助我解决这个问题的想法:)

编辑: 我在 apache 中使用了 mod_python 模块。 请随时询问更多详细信息,

非常感谢!

I have tried Django for a few days, and I'm trying to set up a production project with apache.
I have followed the official tutorial at

http://docs.djangoproject.com/en/1.3/intro/tutorial01/

Everything works just fine with the development server but with apache, I lose every admin style.

I have read similar posts for this issue, without any success from now.

Django admin has no style
Django: ugly admin interface

It may be a rights issue, but I have copied the directory where the media files are stored

/usr/share/pyshared/django/contrib/admin/media/

to the site I server under /data

/data/mysite/
/data/media/
/data/templates/

I have tried different values for /data/mysite/settings.py

/media/, /data/media/,

with the Alias item in the apache configuration as well.

Here is my apache configuration
`
ServerAdmin webmaster@localhost

DocumentRoot /data/sites/accounts/

Alias /media/ /usr/share/pyshared/django/contrib/admin/media/

<Directory />
    Options None
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location />
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined

`

I have the intuition that this is a right issue, but /data/media/ and /data/templates have the same rights/owner and I can modify any template without any problem, and still no style for admin.
Each file served by apache belongs to root:www-data, and 750 for the files, 710 for dirs.

I really thank any of you for any idea helping me to solve this issue :)

EDIT:
I have used for apache the module mod_python.
Don't hesitate to ask for any further details

Thx a lot!

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

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

发布评论

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

评论(2

も星光 2024-11-09 11:40:47

这绝对是 Apache 的问题。您的别名位于 DocumentRoot 之外,但您没有指定对其的访问权限:

http://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias

PS:
如果您不使用 Firebug 这样的工具,您可以输入管理 css 文件之一的 URL,以在浏览器中查看响应是什么(这至少比“无样式”提供更多信息)。

This is definitely an Apache issue. Your Alias is outside of your DocumentRoot, but you're not specifying access to it:

http://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias

P.S.:
If you don't use a tool like Firebug, you could enter the URL of let's say one of the admin css files, to see in your browser what the response is (that's at least more info than "no styles").

请远离我 2024-11-09 11:40:47

我终于解决了这个问题!

我花了一些时间,查看 django 书籍和其他东西,但我在这个链接中发现了解决方案:

Solution_StackOverflow

然后这给出了我的 apache 配置文件:

    Alias /media/css /data/media/css
<Directory /data/media/css>
    Order Allow,Deny
    Allow from all
</Directory>

<Directory />
    Options FollowSymlinks
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location /admin/>
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

我已在 /data/media 复制了媒体文件

我希望这可以帮助遇到同样问题的人。

非常感谢您的帮助!

I finally have solved this issue!

I have spend some time on it, looking on django book and stuff, but I discovered the solution at this link:

Solution_StackOverflow

This then gives my apache configuration file:

    Alias /media/css /data/media/css
<Directory /data/media/css>
    Order Allow,Deny
    Allow from all
</Directory>

<Directory />
    Options FollowSymlinks
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location /admin/>
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

I have copied media files at /data/media

I hope this could help someone having the same trouble.

Thanks a lot for your help!

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