Django管理站点没有显示的CSS样式 [英] Django admin site not showing CSS style
问题描述
我的Django管理网站(这是完全默认情况下,不定制)没有出现预期的CSS。
它看起来是这样的:
和我可以登录:
但它应该是这样的:
我该如何解决这个问题?
其他信息,可以帮助:
我在端口80上的一个Amazon EC2实例上运行,并使用一个真正的URL连接到它。我将它设置使用本教程:
http://www.nickpolet.com/blog/deploying-django-在-AWS / 1 /
随着该教程,我把这个code到一个名为 /etc/apache2/sites-enabled/mysite.conf
。我不明白这是什么code是干什么的,所以我认为这可能与这个问题。
/etc/apache2/sites-enabled/mysite.conf:
WSGIScriptAlias / /home/ubuntu/cs462/mysite/mysite/wsgi.py
WSGIPythonPath /家庭/ Ubuntu的/ cs462 / mysite的
<目录为/ home / Ubuntu的/ cs462 / mysite的/ mysite的>
<文件wsgi.py>
为了否认,允许
要求所有批准
< /文件>
< /目录>别名/媒体/的/ home / Ubuntu的/ cs462 / mysite的/媒体/
别名/静态/的/ home / Ubuntu的/ cs462 / mysite的/静/<目录为/ home / Ubuntu的/ cs462 / mysite的/静态>
要求所有批准
< /目录><目录为/ home / Ubuntu的/ cs462 / mysite的/媒体>
要求所有批准
< /目录>
目录结构:
/家庭/ Ubuntu的/ cs462 /
mysite的/
manage.py
db.sqlite3
mysite的/
__init__.py
__init __。PYC
settings.py
settings.pyc
urls.py
wsgi.py
主页/
admin.py
admin.pyc
__init__.py
__init __。PYC
迁移
models.py
models.pyc
tests.py
views.py
settings.py的过去部分:
#静态文件(CSS,JavaScript,图片)
#https://docs.djangoproject.com/en/1.7/howto/static-files/STATIC_URL ='/静态/
您Apache的配置要求所有静态内容(CSS,JS,图像等)应在mysite的/静态目录。你应该收集应用的静态内容到mysite的/静态目录第一:
CD /家庭/ Ubuntu的/ cs462 / mysite的
蟒蛇manage.py collectstatic
更新:如果您没有静态内容的指定位置,你应该将下列行添加到您的 settings.py
:
STATIC_URL ='/静态/
STATIC_ROOT = os.path.join(BASE_DIR,静态)
My Django admin website (it's completely default, not customized) is not showing the expected CSS.
It looks like this:
And I can log in:
But it is supposed to look like this:
How do I fix this?
Other info that might help:
I'm running on an Amazon EC2 instance on port 80 and connecting to it using a real URL. I set it up using this tutorial: http://www.nickpolet.com/blog/deploying-django-on-aws/1/
Following that tutorial, I put this code into a file called /etc/apache2/sites-enabled/mysite.conf
. I don't understand what this code is doing, so I think it might be related to the problem.
/etc/apache2/sites-enabled/mysite.conf:
WSGIScriptAlias / /home/ubuntu/cs462/mysite/mysite/wsgi.py
WSGIPythonPath /home/ubuntu/cs462/mysite
<Directory /home/ubuntu/cs462/mysite/mysite>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
Alias /media/ /home/ubuntu/cs462/mysite/media/
Alias /static/ /home/ubuntu/cs462/mysite/static/
<Directory /home/ubuntu/cs462/mysite/static>
Require all granted
</Directory>
<Directory /home/ubuntu/cs462/mysite/media>
Require all granted
</Directory>
Directory structure:
/home/ubuntu/cs462/
mysite/
manage.py
db.sqlite3
mysite/
__init__.py
__init__.pyc
settings.py
settings.pyc
urls.py
wsgi.py
homepage/
admin.py
admin.pyc
__init__.py
__init__.pyc
migrations
models.py
models.pyc
tests.py
views.py
Last part of settings.py:
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_URL = '/static/'
Your Apache configuration requires that all static content (CSS, JS, images etc) should be in the mysite/static directory. You should collect your static content from apps into the mysite/static directory first:
cd /home/ubuntu/cs462/mysite
python manage.py collectstatic
Update: If you did not specify a location for static content, you should add the following lines to your settings.py
:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
这篇关于Django管理站点没有显示的CSS样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!