Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.5.x] Refactored proxy model skipping in get_default_columns()

The refactoring allows custom subclasses to use different default
columns than the base model.
  • Loading branch information...
commit a0155f35343afbfd9e98ab9aa4615f06780f697e 1 parent 9e71830
Anssi Kääriäinen authored

Showing 1 changed file with 4 additions and 2 deletions. Show diff stats Hide diff stats

  1. 6  django/db/models/sql/compiler.py
6  django/db/models/sql/compiler.py
@@ -255,8 +255,6 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
255 255
         result = []
256 256
         if opts is None:
257 257
             opts = self.query.model._meta
258  
-        # Skip all proxy to the root proxied model
259  
-        opts = opts.concrete_model._meta
260 258
         qn = self.quote_name_unless_alias
261 259
         qn2 = self.connection.ops.quote_name
262 260
         aliases = set()
@@ -265,6 +263,10 @@ def get_default_columns(self, with_aliases=False, col_aliases=None,
265 263
         if start_alias:
266 264
             seen = {None: start_alias}
267 265
         for field, model in opts.get_fields_with_model():
  266
+            # For local fields (even if through proxy) the model should
  267
+            # be None.
  268
+            if model == opts.concrete_model:
  269
+                model = None
268 270
             if local_only and model is not None:
269 271
                 continue
270 272
             if start_alias:

0 notes on commit a0155f3

Please sign in to comment.
Something went wrong with that request. Please try again.