2021-04-10 01:14:23 +01:00
|
|
|
import os
|
|
|
|
from optparse import make_option
|
|
|
|
|
2023-01-19 18:35:56 +00:00
|
|
|
from django.contrib.auth.models import User
|
2021-04-10 01:14:23 +01:00
|
|
|
from django.core import management
|
|
|
|
from django.core.management.base import BaseCommand, CommandError
|
2023-01-19 18:35:56 +00:00
|
|
|
from django.db import connection
|
2021-04-10 01:14:23 +01:00
|
|
|
|
|
|
|
import settings
|
|
|
|
|
|
|
|
"""this is now replaced by databaseRest.py
|
2021-11-11 17:34:59 +00:00
|
|
|
|
|
|
|
This is an example of how to create our own bespoke commandline
|
|
|
|
commands.
|
|
|
|
|
|
|
|
Good articles on creating Django commands at
|
|
|
|
https://www.mattlayman.com/understand-django/command-apps/
|
|
|
|
https://www.geeksforgeeks.org/custom-django-management-commands/
|
|
|
|
|
|
|
|
Django docs:
|
|
|
|
https://docs.djangoproject.com/en/3.2/howto/custom-management-commands/
|
|
|
|
|
|
|
|
We might use this mechanism to replace/enhance the
|
|
|
|
folk, wallets and any cron jobs or other standalone scripts.
|
2021-04-10 01:14:23 +01:00
|
|
|
"""
|
|
|
|
|
2023-01-30 19:04:36 +00:00
|
|
|
|
2021-04-10 01:14:23 +01:00
|
|
|
class Command(BaseCommand):
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
# Positional arguments
|
2023-01-30 19:04:36 +00:00
|
|
|
parser.add_argument("posargs", nargs="+", type=int)
|
2021-04-10 01:14:23 +01:00
|
|
|
|
|
|
|
# Named (optional) arguments
|
|
|
|
parser.add_argument(
|
2023-01-30 19:04:36 +00:00
|
|
|
"--delete",
|
|
|
|
action="store_true",
|
|
|
|
help="Removed as redundant - use databaseReset.py",
|
2021-04-10 01:14:23 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
print(args)
|
|
|
|
print(options)
|