#30587: Exceptions thrown by 'get_object_or_404()' shortcut method
-----------------------------------------+------------------------
Reporter: Killer-I | Owner: nobody
Type: New feature | Status: new
Component: Uncategorized | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-----------------------------------------+------------------------
When we use get_object_or_404() method to query an object, sometimes due
to invalid inputs it will through exceptions. Instead can it raise 404
directly?
Ex:
Models:
>>class Test1(models.Model):
>> c2 = models.CharField(max_length=10)
>>class Test2(models.Model):
>> c1 = models.UUIDField(primary_key=True, default=uuid.uuid4)
>> c2 = models.CharField(max_length=10)
query:
1. Below statement raises valueError:
>> get_object_or_404(Test1, pk='test')
>> - invalid literal for int() with base 10: 'test'
2. Below statement raises ValidationError:
>> get_object_or_404(Test2, pk="test")
>> - 'test' is not a valid UUID.
So this method will throw diffrent exceptions in diffenrent scenario. So
would it be possible to raise 404 exceptions even if it finds invalid
values.
--
Ticket URL: <https://code.djangoproject.com/ticket/30587>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.37b1a8081e5d1eb5d1acbfdd18c508b1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.