Skip to content

Instantly share code, notes, and snippets.

@victorono
Created January 5, 2014 01:11
Show Gist options
  • Save victorono/8263015 to your computer and use it in GitHub Desktop.
Save victorono/8263015 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.conf import settings
from django.core.cache import cache
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = 'Fully clear your site-wide cache.'
def handle(self, *args, **kwargs):
try:
assert settings.CACHES
cache.clear()
self.stdout.write('Your cache has been cleared!\n')
except AttributeError:
raise CommandError('You have no cache configured!\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment