diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index d7e19ad25bc..84c81f9e218 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -392,13 +392,13 @@ class Field(RegisterLookupMixin): return [] def get_col(self, alias, output_field=None): - if output_field is None: - output_field = self - if alias != self.model._meta.db_table or output_field != self: - from django.db.models.expressions import Col - return Col(alias, self, output_field) - else: + if ( + alias == self.model._meta.db_table and + (output_field is None or output_field == self) + ): return self.cached_col + from django.db.models.expressions import Col + return Col(alias, self, output_field) @cached_property def cached_col(self):