Pouya
Pouya

Reputation: 2177

Where are Django Admin Site's static media files? and How to configure?

So far, I have been using a stable release of django: 1.3, and my settings.py looked like this (for admin site):

STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'

I just switched to development version, and once I ran the server, got the following warning:

DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use STATIC_URL instead.
 "use STATIC_URL instead.", DeprecationWarning)

AND, my admin site looks different now (without all the css, javascript, etc).

I tried changing the static url to different possibilities, and got rid of admin media prefix altogether, but the original look of admin site was not retrieved.

Can someone tell me how to configure this?

Upvotes: 2

Views: 4419

Answers (1)

Bite code
Bite code

Reputation: 596783

In the next Django version, static files handling behave like the old django-staticfiles app:

  • to ensure that you got all static files from all apps, convention is put each app static file in a subdir called 'static'
  • on dev, everything is served automatically by the dev server
  • on prod, everything is statically served from one directory with your HTTP prod server. To fill this directory, use ./manage.py collectstatic

So you don't need ADMIN_MEDIA_PREFIX because the admin static files will be either served automatically during dev, or collected automatically by collectstatic during prod.

STATIC_URL should match the URL you will serve the static content, ALL of it, in prod. STATIC_ROOT should be the absolute path to the directory where you want the static files to be copied by collectstatic.

Upvotes: 2

Related Questions