top | item 40805025

(no title)

c6401 | 1 year 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')

discuss

order

No comments yet.