rulzart
rulzart

Reputation: 113

Using same static folder on multiple django sites

I have a website that consists of one main website and several subsites (and more are coming).

The thing is, the main site and the subsites has the same layout, uses the same js etc., so I want to ask if it's possible for all the sites to share a single static folder?

The static folder is 130 mb. atm. I find it kinda redundant that I need to copy that folder every time a new site is created. With 200 sites (a somewhat realistic goal), it would be 20 gb space wasted on duplicate files.

So is there a way to do this? I know it is somewhat against good django practice (no use of collectstatic)

Upvotes: 0

Views: 88

Answers (2)

rulzart
rulzart

Reputation: 113

AdamKG gave me the "right" answer - at least for my needs. I might move to S3 at some point, when it's more relevant.

"Well, the easy hacks are symlinks & related. The question you should be asking, though, is why you're using django projects as a unit of what seems to be (going by count ~ 200) a commodity. IOW: why do the sites have separate anything, including static media, instead of just being rows in a table? "

Upvotes: 0

Brandon Taylor
Brandon Taylor

Reputation: 34593

In a situation like this, I would use Amazon S3 and CloudFront. You can transparently upload all of your static files to your S3 bucket using django-storages when you run collect static by replacing the default file upload mechanism with boto + s3 as such:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

As @AdamKG stated, if all of these sites share the same code, with different content, you're probably better off using Django-CMS or moving these sites to database records rather than deploying the same code over and over.

Upvotes: 1

Related Questions