22 lines
521 B
Python
22 lines
521 B
Python
import os
|
|
import shutil
|
|
|
|
from django.apps import AppConfig
|
|
from django.conf import settings
|
|
|
|
|
|
class MainConfig(AppConfig):
|
|
default_auto_field = "django.db.models.BigAutoField"
|
|
name = "project.main"
|
|
|
|
def ready(self):
|
|
"""copy template database if db not exists"""
|
|
|
|
db_fname = settings.DATABASES["default"]["NAME"]
|
|
template_db_fname = settings.BASE_DIR / "db.template.sqlite3"
|
|
|
|
if os.path.exists(db_fname):
|
|
return
|
|
|
|
shutil.copyfile(template_db_fname, db_fname)
|