开发者

CSS broken on Django admin on developer server

I'm getting some really weird issues with the Django admin application. I'm running everything on the manage.py runserver development server, so I can't imagine what the issue would be, but I'm seeing something like this:

CSS broken on Django admin on developer server

Obviously, this isn't ideal, so I'd like to return it to actually looking good. I'm using the staticfiles app, which I think might be a part of the problem, but I don't know for sure. What am I doing wrong here?

The admin site seems to link to the following CSS sheets, which aren't being found:

<link rel="stylesheet" type="text/css" hre开发者_Go百科f="/media/css/base.css" />
<link rel="stylesheet" type="text/css" href="/media/css/dashboard.css" />


I'm assuming you mean you're using the staticfiles contrib package in Django 1.3. If that's correct, you only need:

ADMIN_MEDIA_PREFIX = STATIC_URL+'admin/'


In settings.py uncomment(if commented) or add 'django.contrib.staticfiles', and restart the server. This should fix it.


You've probably got your ADMIN_MEDIA_PREFIX set incorrectly.

Try setting it to:

ADMIN_MEDIA_PREFIX = "/admin-media/"

And see if that fixes everything.

Ok, three more things to check:

  1. Just a sanity check: are the admin stylesheets which are 404ing actually prefixed with /admin-media/?
  2. Is there any chance that your custom URL handlers are matching? (ex, do you have something like url(r'^admin-media/', …) in your root urls.py?
  3. It's unlikely, but is there any chance your Django install could be broken? do the .css files actually exist in …/site-packages/django/contrib/admin/static/admin?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜