Миграции.runsql

def set_pg_sequence(apps, schema_editor):
    if connection.vendor == "postgresql":
        # Reset sequence of user so Postgres doesn't crash on an existing user
        # ID 100 for our uploader user.
        # http://stackoverflow.com/a/3698777/85461
        migrations.RunSQL(
            """
            SELECT pg_catalog.setval(
                pg_get_serial_sequence('auth_user', 'id'), MAX(id)
            ) FROM auth_user;
            """.format(table_name=settings.AUTH_USER_MODEL)
        )
Annoyed Antelope