Created
May 11, 2020 00:08
-
-
Save godfather68/aa4ab9340d76dd8098c5b9d35b15aa53 to your computer and use it in GitHub Desktop.
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
from django.core.management.base import BaseCommand | |
import os | |
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
class Command(BaseCommand): | |
help = "Templates Generator" | |
template_dir = os.path.join(BASE_DIR, 'templates') | |
file_path = os.path.join(template_dir, '_base.html') | |
def handle(self, *args, **kwrags): | |
self.stdout.write("Generating _base.html template ...") | |
self.stdout.write('----------------------------------') | |
def directory_checker(self): # <= new from here | |
# Checking if the directory exists | |
if os.path.exists(self.template_dir): | |
self.stdout.write("Checking if 'templates' directory exists ... Done") | |
return self.template_dir | |
else: | |
self.stdout.write("Checking if 'templates' directory exists ... Missing") | |
self.stdout.write("Creating templates directory") | |
os.makedirs(self.template_dir) | |
self.directory_checker() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment