Created
November 17, 2016 10:59
-
-
Save morty/f8b5a4c1018e173aa57b6b2ed7037517 to your computer and use it in GitHub Desktop.
Simple Django management command to run the application at a given timestamp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand | |
from django.core.management import call_command | |
from freezegun import freeze_time | |
class Command(BaseCommand): | |
help = 'Run application at given time' | |
def add_arguments(self, parser): | |
parser.add_argument('timestamp', nargs='?', | |
help='Timestamp to run application at') | |
parser.add_argument('addrport', nargs='?', | |
help='Optional port number, or ipaddr:port') | |
def handle(self, *args, **options): | |
with freeze_time(options['timestamp']): | |
call_command('runserver', *args, **options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment