Code

Opened 2 years ago

Closed 2 years ago

#17773 closed Uncategorized (worksforme)

Django does not catch ProtectedError when DEBUG=True

Reported by: anonymous Owned by: nobody
Component: Uncategorized Version: 1.4-beta-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Django does not catch ProtectedError when DEBUG=True

It return:
A server error occurred. Please contact the administrator.

class A(models.Model):
   ...

class B(models.Model):
    link = models.ForeignKey(A, on_delete=models.PROTECT)


a = A.objects.get(pk=1)
B.objects.create(link=a)
a.delete()

Attachments (0)

Change History (1)

comment:1 Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

Just tested with current code, and I cannot reproduce your bug. I got a proper exception page:

ProtectedError at /

("Cannot delete some instances of model 'Sample' because they are referenced through a protected foreign key:
 'Test.link'", [<Test: Test object>])
...

You should try to debug your project to see why it is failing for you (django/core/handlers/base.py, around the handle_uncaught_exception method).

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.