Note that there are some explanatory texts on larger screens.

plurals
  1. POChaining management commands from a Custom Django Command
    primarykey
    data
    text
    <p>I am doing some file aggregation / generation and want to immediately run collectstatic afterwards. Ideally I either extend the collectstatic command (i don't know if this is possible) or I chain control to that command. I have tried the second, which isnt working:</p> <pre><code>class Command(BaseCommand): can_import_settings = True def handle(self, *args, **options): something_necessary() execute_from_command_line('collectstatic') </code></pre> <p>Many thanks in advance from this django newbie.</p> <p>Edit running from the command line is interesting</p> <pre><code>C:\www\app&gt;python manage.py customCmd ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb' </code></pre> <p>Well OK - that is interesting, as my command doesn't use the MySQLdb. But trying the collectstatic separately works:</p> <pre><code>C:\www\app&gt;python manage.py collectstatic C:\Python33\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py:65: DeprecationWarning: stat_float_times() is deprecated os.stat_float_times(False) You have requested to collect static files at the destination location as specified in your settings. This will overwrite existing files! Are you sure you want to do this? </code></pre> <p>If I write the command as simple as</p> <pre><code>from django.core.management.base import BaseCommand class Command(BaseCommand): can_import_settings = False def handle(self, *args, **options): pass </code></pre> <p>I get the MySQLdb error from a command line run. </p> <p>SO what I know </p> <ol> <li>it works fine from PyCHarm IF i dont make the call to execute_from_command_line</li> <li>I can't get my custom command to execute from the command line (python manage,py customCmd)</li> <li>the collectstatic works fine from both the PyCHarm interface and the command line</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload