ADMIN_MEDIA_PREFIX deprecation and using static files in Django 1.4

Go To StackoverFlow.com

1

I have a django 1.3 based frontend and it serves all the static files from Amazon S3. I am wishing to upgrade to Django 1.4. It seems that Django has changed the way admin static files are rendered. I have the following configuration:

settings.py: I have the app django.contrib.staticfiles in INSTALLED_APPS (in both 'dev' and 'prod' settings). The static content is live on Amazon S3.

I am testing changes on my dev machine (DEBUG=True), but the /admin page is not able to render the static files and icons. That is because it is trying to pull stuff from S3 (because django.contrib.staticfiles is installed), but not pulling in from the dev django folders. Is there a way in which I can force the content out from dev folders when DEBUG = True rather than pulling in from S3?

2012-04-05 20:14
by Rajat


2

Try setting STATIC_URL based on DEBUG:

if DEBUG:
    STATIC_URL = "/static/"
else:
    STATIC_URL = "http://external.domain.com/"

Then make sure you've added the static files url patterns to your url config

2012-04-05 23:37
by Alasdair
Yeah, I have added that. That works with 1.3 but not with 1. - Rajat 2012-04-09 19:40
What is not working with 1.4? Is the link to the static files still pointing to the external domain in debug mode? Or is the dev server not serving the files? If it's the latter, you could update your answer with your settings and your URL configuration and somebody might be able to spot if you've made a mistake - Alasdair 2012-04-09 21:03
Ads