Difference between revisions of "Django Management command"
Jump to navigation
Jump to search
Rafahsolis (talk | contribs) (Created page with "app_dir/management/commands/cmdname.py<syntaxhighlight lang="python3"> from django.core.management.base import BaseCommand, CommandError class Command(BaseCommand): def...") Tag: visualeditor |
Rafahsolis (talk | contribs) m Tag: visualeditor |
||
| Line 5: | Line 5: | ||
class Command(BaseCommand): | class Command(BaseCommand): | ||
def add_arguments(self, parser): | def add_arguments(self, parser): | ||
| − | + | parser.add_argument('path', help='File path') | |
def handle(self, *args, **options): | def handle(self, *args, **options): | ||
| − | + | print(f'{options['path']}') | |
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 08:38, 27 April 2020
app_dir/management/commands/cmdname.py
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('path', help='File path')
def handle(self, *args, **options):
print(f'{options['path']}')