﻿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
29907	Allow QuerySet.get() and filter() to accept a positional argument for implicit primary key filtering	Antoine	nobody	"I'm creating this ticket to see if there is interest to implement positional arguments in queryset filtering.

== Current situation ==

Currently the only way to use positional arguments to filter can be either:

* Passing a single or multiple Q objects:
{{{
MyClass.objects.filter(Q(key=value))
MyClass.objects.filter(Q(key=value), Q(other_key=value))
}}}

* Passing a couple is also working (not sure if this is a happy accident)
{{{
MyClass.objects.filter((key, value))
}}}

* Combination of both is also proven to work
{{{
MyClass.objects.filter((key, value), Q(other_key=value))
}}}

== Suggestion ==

My feature suggestion is to leverage the case when a non-Q / non couple object is passed, so it implicitly interpreted as the value for the model's `pk`.

This could ease/simplify code by omitting `pk` when this is the only filter used:

{{{
MyClass.objects.get(value)
# Translates into: MyClass.objects.get(pk=value)
}}}

or

{{{
MyClass.objects.filter(value)
# Translates into: MyClass.objects.filter(pk=value)
}}}

or 

{{{
MyClass.objects.filter(Q(value))
# Translates into: MyClass.objects.filter(Q(pk=value))
}}}


Do you think it's worth it? It could be leveraged to simplify many situations."	New feature	closed	Database layer (models, ORM)	dev	Normal	wontfix			Unreviewed	0	0	0	0	0	0
