1

I am using django-mediagenerator for managing static files. It has been great, but I am trying to figure out how I could put the static files on a content delivery network. I will be using Amazon AWS.

The way I see it, I could do one of two things:

  • Upload the files to the CDN, and configure mediagenerator/django to point to the CDN's url
  • Upload the files to the CDN and configure Apache to serve the files from CDN

However, both of these do not strike me as particularly straight forward.

Does one of those solutions sound better than the other one? Is there a different way of doing this?

NT3RP
  • 15,262
  • 9
  • 61
  • 97
Goro
  • 9,919
  • 22
  • 74
  • 108

1 Answers1

2

I had this same challenge, and chose to use Django's 'collectstatic' management command to upload the files to AWS using django-storages and python-boto:

STATICFILES_DIRS = (
    os.path.join(CURRENT_DIR, '_generated_media'),
)
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

Then, I pointed django-mediagenerator to the applicable S3 bucket:

PRODUCTION_MEDIA_URL = 'http://bucketname.s3.amazonaws.com/static/'

I don't think there's a built-in way for django-mediagenerator to use a custom storage backend when it runs the generatemedia command, though that would be the best solution, imho.

mjacksonw
  • 491
  • 4
  • 8