Added custom_migrate command to simplify migrating with spatialite backend

This commit is contained in:
Keannu Bernasol 2023-07-09 21:20:09 +08:00
parent 4c3b8763a8
commit 1fc262a530
3 changed files with 14 additions and 0 deletions

View file

View file

@ -0,0 +1,14 @@
from django.core.management.base import BaseCommand
from django.db import connection
from django.core.management import call_command
class Command(BaseCommand):
help = 'Run InitSpatialMetaData and then migrate'
def handle(self, *args, **kwargs):
with connection.cursor() as cursor:
cursor.execute('SELECT InitSpatialMetaData(1);')
# Call the Django migrate command
call_command('migrate')