Currently the only way to use positional arguments to filter can be either:
MyClass.objects.filter(Q(key=value)) MyClass.objects.filter(Q(key=value), Q(other_key=value))
MyClass.objects.filter((key, value))
MyClass.objects.filter((key, value), Q(other_key=value))
This 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))
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/a29eed0a-687a-4964-aec3-a25eeeb6f441%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAFv-zfLVpgrSdiFp1w0-9jLsDUG%2BrA7Fo7L89kWREVeYDCnM3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM0ZRdc11qCY-JiRwUuuTDDkM0yCxN8%3DmGx5LDR9iNiAmQ%40mail.gmail.com.
I feel this would be a good addition to just .get()
, I’ve wanted this while working with the shell. Model.objects.get(pk)
feels very natural to me, and the common Model.objects.get(pk=pk)
always felt overly verbose.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/ba9128d7-9e49-4269-b3a3-9995a998b491%40googlegroups.com.
I still don't understand the problem this is solving; is typing "pk=" (or "id=") that much of a burden? Or that frequently left out by accident?As it stands, I agree with Adam that this adds implementation complexity (including potential future implementation complexity, as Ivan noted) and proliferates different ways to do the same thing, without presenting much in the way of concrete arguments for why it's needed. If there's a really convincing case to be made for this, I'm open to reading it when it's made, but for now I'd be -1 on the whole thing.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAL13Cg9ocm_LmZSGbQG%3DEB2U0Z%2BOF5eupJFwK3OWbyz46JDj5Q%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/4bdacfe9-8fca-4b59-a15d-27553c731d4e%40googlegroups.com.