fix ./manage.py orphaned_media

This commit is contained in:
j 2013-09-26 15:27:43 +00:00
parent 3064785b3e
commit 4b575c2c89

View file

@ -4,17 +4,18 @@ from django.core.management.base import BaseCommand
from django.conf import settings
import os
from glob import glob
from ... import models
import app.monkey_patch
from ... import models
class Command(BaseCommand):
"""
"""
help = 'list files no longer without db entry'
help = 'list files without db entry'
args = ''
def handle(self, **options):
for f in glob(os.path.join(settings.MEDIA_ROOT, 'files', '*', '*', '*', '*')):
for f in glob(os.path.join(settings.MEDIA_ROOT, 'media', '*', '*', '*', '*')):
oshash = f[-19:].replace('/', '')
if models.File.objects.filter(oshash=oshash).count() == 0:
print f