akolpakov / django-unused-media

Remove unused media files from Django project
MIT License
126 stars 25 forks source link

'Options' object has no attribute 'get_fields' error encountered #7

Closed jerickbixly closed 7 years ago

jerickbixly commented 7 years ago

hi

i recently installed this on a django project i'm working on to do cleanups of my unused media files. I ran the cleanup_unused_media command with my virtualenv enabled and i got the following result. I tried it with

python manage.py cleanup_unused_media

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django_unused_media/management/commands/cleanup_unused_media.py", line 32, in handle
    unused_media = get_unused_media(options.get('exclude') or [])
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django_unused_media/cleanup.py", line 91, in get_unused_media
    used_media = get_used_media()
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django_unused_media/cleanup.py", line 43, in get_used_media
    for f in _get_file_fields():
  File "/home/dev/.virtualenvs/TestProject/local/lib/python2.7/site-packages/django_unused_media/cleanup.py", line 29, in _get_file_fields
    for f in m._meta.get_fields():
AttributeError: 'Options' object has no attribute 'get_fields'

i tried running it with the option --noinput enabled but i got the following error

python manage.py cleanup_unused_media --noinput
Usage: manage.py cleanup_unused_media [options] 

Clean unused media files which have no reference in models

manage.py: error: no such option: --noinput

Is there a missing option for this which is why it's not running? I've installed django_unused_media in my INSTALLED_APPS as well. Thanks.

Edit: Forgot to note that i'm using Django 1.7.

jerickbixly commented 7 years ago

Looks like it's related to other libraries i'm using. closing this now