generated from dhmit/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added launch_site management command
- Loading branch information
1 parent
dca8794
commit 8cc1abd
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
""" | ||
Django management command launch_site | ||
""" | ||
|
||
import platform | ||
import subprocess | ||
|
||
from django.core.management.base import BaseCommand | ||
from django.core.management import call_command | ||
|
||
|
||
class Command(BaseCommand): | ||
""" | ||
Custom django-admin command to launch the local website | ||
""" | ||
|
||
help = "Custom django-admin command to launch the local website" | ||
|
||
def handle(self, *args, **options): | ||
on_windows = platform.system() == "Windows" | ||
frontend_cmd = [f"npm{".cmd" if on_windows else ""}", "run", "start"] | ||
frontend = subprocess.Popen(frontend_cmd) | ||
call_command("runserver") | ||
frontend.kill() |