diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py index 13093e729d..65ab599858 100644 --- a/django/db/backends/base/schema.py +++ b/django/db/backends/base/schema.py @@ -291,12 +291,12 @@ class BaseDatabaseSchemaEditor: ), } db_tablespace = None - if settings.DATABASES[self.connection.alias].get("DEFAULT_TABLESPACE"): + if model._meta.db_tablespace: + db_tablespace = model._meta.db_tablespace + elif settings.DATABASES[self.connection.alias].get("DEFAULT_TABLESPACE"): db_tablespace = settings.DATABASES[self.connection.alias][ "DEFAULT_TABLESPACE" ] - elif model._meta.db_tablespace: - db_tablespace = model._meta.db_tablespace if db_tablespace: tablespace_sql = self.connection.ops.tablespace_sql(db_tablespace) if tablespace_sql: