سؤال

Like we can see here:

https://docs.djangoproject.com/en/1.6/ref/models/querysets/#get

Entry.objects.get(id='foo')

Shouldn't only Entry.objects.get(id__exact='foo') acceptable? Can we substitute id with other fields like get(name='bar')?

هل كانت مفيدة؟

المحلول

And a little deeper in...

If you don’t provide a lookup type – that is, if your keyword argument doesn’t contain a double underscore – the lookup type is assumed to be exact.

And yes, you can use any field you can provide an equivalent Python type for.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top