On Oct 23, 2017 4:06 PM, "'Aaron C. de Bruyn' via Django users" <
django-users@googlegroups.com> wrote:
The difference between .filter() and .get() is definitely 'by-design'.
When you filter through a list of objects, you could end up with zero,
one, or many objects returned.
When you call .get(
Thank you Aaron, I started to figure this all out too as I read the docs
more carefully and looked at the source code more thoughtfully.
One nuance on the try/except block you propose: doesn't work as expected in
the request framework because even though the except block can be stated as
you pr
The difference between .filter() and .get() is definitely 'by-design'.
When you filter through a list of objects, you could end up with zero,
one, or many objects returned.
When you call .get(), you are basically saying "I want to get exactly
*one* record". If the record is not found, it is cons
Replying to myself here: as is often the case, the problem lies with my own
source code.
I was calling
MODELNAME.objects.get(modelfieldname1='foo',modelfieldname2='bar')
which raises the 500 when no such record exists.
Turns out that calling
MODELNAME.objects.filter(modelfieldname1='foo',modelf
I have been tripping over the following exception
DoesNotExist: INSERT_YOUR_MODEL_NAME_HERE matching query does not exist.
The error is source in django 1.11.2 in db.models query.py file, in the
get(self, *args, **kwargs) function, line 378 to be exact
...
raise self.model.DoesNotExist(...)
.
5 matches
Mail list logo