Задать вопрос

Тел: +7 965 3737 888

503

Просмотров

4

Ответов

collectmedia command: Copy or link media files from installed apps

<p>This management command discovers media files from all INSTALLED_APPS (or the apps you specify) and copies or links them to MEDIA_ROOT.  Put this code in a file like so:
</p>
yourapp/management/commands/collectmedia.py
<p>...and don't forget the necessary __init__.py files.
</p>
<p>This command includes an interactive mode (-i or --interactive) and a dry run mode (-n or --dry-run) for previewing what will happen.  See manage.py help collectmedia for more options.
</p>

Вопрос полезен? Да0/Нет0
file_3564.py(9.3Кб)
None

Ответы (4):

Ответsorin:10.08.2010
Ответ полезен? Да0/Нет0

To make this work on Windows add these lines before class definition:

try: #hack for Windows where lchown does not exists yet
    a = os.getattr('lchown')
except:
    def nop(*params):
        pass
    os.lchown = nop

Ответexogen:17.10.2009
Ответ полезен? Да0/Нет0

@simeonf: Fixed. Thanks!

Ответsimeonf:30.04.2009
Ответ полезен? Да0/Нет0

Why the call to dirname on line 39? I had to take this out to work (and I'm pretty sure you actually want the media_root, not it's parent directory). Maybe this is to strip out trailing slashes?

Ответexogen:19.09.2008
Ответ полезен? Да0/Нет0

See the installmedia thread on django-developers for more information and ideas.