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

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

问题描述

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 admin 没有风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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