Django管理员没有风格 [英] Django admin has no style

查看:108
本文介绍了Django管理员没有风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的登台服务器上移动了我的django站点,站点的管理员端没有它的样式,以前在本地开发是好的,我读到某处,我需要创建一个符号链接,我这样做

  sudo ln -s / var / www / sico / htdocs /usr/lib/python2.5/ site-packages / django / contrib / admin / 

但是没有做任何其他事情可以尝试吗?

解决方案

根据您的Web服务器设置,您可以通过两种方法之一:



Symlinking



在您的网站的根文件夹中,您应该创建一个符号链接到您的Django管理媒体目录,名称为您的Django应用的设置中的 ADMIN_MEDIA_PREFIX 默认情况下,这是 / media / ,所以在您的Web根文件夹中,创建一个名为 media 的符号链接到 /usr/lib/python2.5/site-packages/django/contrib/admin/media 。 (请注意符号链接末尾的媒体,这在您自己的示例中丢失 - Django管理媒体位于 media contrib / admin`中的$ code>子目录



Apache Alias



如果您的生产服务器是Apache,并且您可以更改根配置,您可以使用 mod_alias 设置Django管理媒体的路径。再次,假设您的 ADMIN_MEDIA_PREFIX / media / ,则可以设置如下所示的别名:

 < VirtualHost *:80> 
别名/媒体/ /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/
< / VirtualHost>

这样,路径下的所有请求 / media / 将被解析到该目录。



对于大多数其他服务器,如Lighttpd或nginx,存在类似的技术;如果您不使用Apache,请咨询服务器的文档。






使用Apache的 mod_alias 可能最适合部署,但是符号链接方法也是如此。



您的应用程序在您的登台服务器上工作的原因很可能是因为它正在与Django的内部Web服务器一起运行,可以自动解决管理媒体目录的路径。


I have just moved my django site on my staging server, and the admin side of the site has no styling with it, when previously in local development it was fine, I read somewhere that I need to create a symbolic link, I did that by doing this

sudo ln -s /var/www/sico/htdocs /usr/lib/python2.5/site-packages/django/contrib/admin/

but that has done nothing is there anything else that I can try?

解决方案

Depending on your web server setup, you can do it one of two ways:

Symlinking

In your website's root folder, you should create a symbolic link to your Django admin media directory, with the name name as the ADMIN_MEDIA_PREFIX in your Django app's settings. By default this is /media/, so in your web root folder, create a symlink called media to /usr/lib/python2.5/site-packages/django/contrib/admin/media. (Note the trailing media on the end of the symlink, which is missing from your own example -- the Django admin media is located in a media subdirectoryincontrib/admin`).

Apache Alias

If your production server is Apache, and you can change the root configuration, you can use mod_alias to set up the path to Django admin media. Again, assuming that your ADMIN_MEDIA_PREFIX is /media/, you can set up an alias like so:

<VirtualHost *:80>
  Alias /media/ /usr/local/lib/python2.5/site-packages/django/contrib/admin/media/
</VirtualHost>

This way, all requests under the path /media/ will be resolved to that directory.

A similar technique exists for most other servers, such as Lighttpd or nginx; consult your server's documentation if you don't use Apache.


The solution using Apache's mod_alias is probably best for deployment, but the symlinking approach works just as well too.

The reason your app worked on your staging server is most likely because it was running with Django's internal web server, which can automatically resolve the path to the admin media directory.

这篇关于Django管理员没有风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆