Changes between Initial Version and Version 2 of Ticket #30587


Ignore:
Timestamp:
Jun 24, 2019, 1:28:46 AM (5 years ago)
Author:
Mariusz Felisiak
Comment:

Duplicate of #22303.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30587

    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Resolutionduplicate
    • Property Status newclosed
    • Property Summary Exceptions thrown by 'get_object_or_404()' shortcut methodCloaking exceptions raised by get_object_or_404().
    • Property Version 2.2master
  • 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