Skip to content

Instantly share code, notes, and snippets.

@justquick
Created August 27, 2010 17:42
Show Gist options
  • Save justquick/553795 to your computer and use it in GitHub Desktop.
Save justquick/553795 to your computer and use it in GitHub Desktop.
from django.conf import settings
from django.db.models import get_models, FileField
from django.core.files.storage import get_storage_class
STORAGE = get_storage_class(getattr(settings, "STORAGE", settings.DEFAULT_FILE_STORAGE))
for model in get_models():
for field in model._meta.fields:
if isinstance(field, FileField) and not isinstance(field.storage, STORAGE):
FileField(verbose_name=field.verbose_name, upload_to=field.upload_to, name=field.name).\
contribute_to_class(model, field.name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment