Ticket #16472: clean.diff
File clean.diff, 1.3 KB (added by , 13 years ago) |
---|
-
django/db/models/query.py
226 226 only_load = self.query.get_loaded_field_names() 227 227 if not fill_cache: 228 228 fields = self.model._meta.fields 229 pk_idx = self.model._meta.pk_index()230 229 231 230 load_fields = [] 232 231 # If only/defer clauses have been specified, … … 235 234 for field, model in self.model._meta.get_fields_with_model(): 236 235 if model is None: 237 236 model = self.model 238 if field == self.model._meta.pk:239 # Record the index of the primary key when it is found240 pk_idx = len(load_fields)241 237 try: 242 238 if field.name in only_load[model]: 243 239 # Add a field that has been explicitly included … … 276 272 else: 277 273 if skip: 278 274 row_data = row[index_start:aggregate_start] 279 pk_val = row_data[pk_idx]280 275 obj = model_cls(**dict(zip(init_list, row_data))) 281 276 else: 282 277 # Omit aggregates in object creation.