Changes between Initial Version and Version 2 of Ticket #30587


Ignore:
Timestamp:
06/24/2019 01:28:46 AM (2 years ago)
Author:
Mariusz Felisiak
Comment:

Duplicate of #22303.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30587

    • Property Status changed from new to closed
    • Property Component changed from Uncategorized to Database layer (models, ORM)
    • Property Summary changed from Exceptions thrown by 'get_object_or_404()' shortcut method to Cloaking exceptions raised by get_object_or_404().
    • Property Version changed from 2.2 to master
    • Property Resolution changed from to duplicate
  • Ticket #30587 – Description

    initial v2  
    33
    44Models:
     5{{{
    56>>class Test1(models.Model):
    67>>    c2 = models.CharField(max_length=10)
     
    910>>    c1 = models.UUIDField(primary_key=True, default=uuid.uuid4)
    1011>>    c2 = models.CharField(max_length=10)
    11 
     12}}}
    1213query:
    13141. Below statement raises valueError:
     15{{{
    1416    >> get_object_or_404(Test1, pk='test')
    1517    >> - invalid literal for int() with base 10: 'test'
    16 
     18}}}
    17192. Below statement raises ValidationError:
     20{{{
    1821    >> get_object_or_404(Test2, pk="test")
    1922    >> - 'test' is not a valid UUID.
    20 
    21 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.
     23}}}
     24So this method will throw different exceptions in different scenario. So would it be possible to raise 404 exceptions even if it finds invalid values.
Back to Top