Probably the easiest way to implement this is with a custom management command [Django-doc]. In your amazon
app, yoou can define a management command:
amazon/
management/
commands/
amazonpay.py
# …
In that amazonpay.py
file, you then implement the custom management command:
# amazon/management/commands.amazonpay.py
from django.core.management.base import BaseCommand
from amazon.models import Amazon
class Command(BaseCommand):
help = 'Some description...'
def handle(self, *args, **options):
# … run selenium …
Amazon.objects.create(
o=ord_id
)
You can then run this command with:
python3 manage.py amazonpay
In fact runserver
, makemigrations
, etc. are all defined as management commands as well.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…