Hacker News new | ask | show | jobs
by c6401 718 days ago
I hanen't touched Django in some time, but something like this should work:

    from django.db import models
    from django.db import connection

    class MyModel(models.Model):
        name = models.CharField(max_length=255)

        class Meta:
            app_label = 'myapp'


    with connection.schema_editor() as schema_editor:
        schema_editor.create_model(MyModel)

    # from django.core.management import call_command
    # call_command('makemigrations', 'myapp')
    # call_command('migrate', 'myapp')