[Django]-How to programatically create a database view in Django?

5👍

✅

Django’s migrations framework lets you execute raw SQL – https://docs.djangoproject.com/en/3.1/ref/migration-operations/#runsql

So, you could create an empty migration (manage.py makemigrations <appname> --empty) and then edit it to execute your view-creating SQL via a migrations.RunSQL() call.

0👍

Maybe you should try this with the get_view_str method https://pypi.org/project/django-database-view/#description

Leave a comment