﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37505	Django 6.1: TypeError in Query.add_select_col() when combining QuerySets with Meta.ordering referencing related model fields	Ulrich Görtz		"The following problem occurs with Django 6.1, PostgreSQL, Python 3.14.

For a model (with a regular primary key) and Meta.ordering referencing fields through a foreign key (`ordering = ('user__lastname', )`, say), QuerySet.difference() applied to two QuerySets of that model (e.g., as a trivial example, `A.objects.all().difference(A.objects.all())`) throws a TypeError during SQL compilation because query.selected is None.

Adding .order_by() without arguments to the difference method resolves the problem.

The same query worked in Django 6.0. The problem might be related to #37466

Thanks for your work."	Bug	new	Database layer (models, ORM)	6.1	Low			Ulrich Görtz	Unreviewed	0	0	0	0	0	0
