gold eggs backend
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
Some checks failed
Build and Push to Docker Hub / build-test-push (push) Failing after 1m55s
This commit is contained in:
31
core/console/management/commands/makeapp.py
Executable file
31
core/console/management/commands/makeapp.py
Executable file
@@ -0,0 +1,31 @@
|
||||
"""
|
||||
Create a new app in django project command
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management import base
|
||||
|
||||
|
||||
class Command(base.BaseCommand):
|
||||
help = "Generate new app"
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument("name")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
name = options.get("name")
|
||||
|
||||
if os.path.exists(
|
||||
os.path.join(settings.BASE_DIR, f"core/apps/{name}")
|
||||
):
|
||||
self.stdout.write(self.style.ERROR(f"App {name} already"))
|
||||
return
|
||||
try:
|
||||
os.system(
|
||||
f"cd ./core/apps && python3 ./../../manage.py startapp {name}"
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(f"Make app {name} created"))
|
||||
except Exception as e:
|
||||
self.stdout.write(self.style.ERROR(f"Error: {e}"))
|
||||
Reference in New Issue
Block a user