Code

Opened 6 years ago

Closed 6 years ago

Last modified 3 years ago

#7517 closed (fixed)

Site.objects.get_current() returns deleted objects

Reported by: telenieko Owned by: telenieko
Component: Contrib apps Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

#7514 lead to find this bug.

>>> from django.contrib.sites.models import Site
>>> s = Site.objects.get_current()
>>> s
<Site: example.com>

>>> s.delete()
>>> Site.objects.get_current()
<Site: example.com>

Obviously, the last one should be a DoesNotExist. Patch incoming.

Attachments (1)

site_delete.diff (1.1 KB) - added by telenieko 6 years ago.
Remove Site from CACHE on delete.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by telenieko

Remove Site from CACHE on delete.

comment:1 Changed 6 years ago by telenieko

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to telenieko
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Ready for checkin

Attached patch overrides Site.delete() to delete the Site from the SITE_CACHE.
Includes a test.

comment:2 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7724]) Fixed #7517 -- Added code to remove Sites from the site cache when they are deleted. Thanks to Marc Fargas for the patch.

comment:3 Changed 3 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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.