Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing related child objects (deleted ones) #545

Open
eddielu opened this issue Jul 13, 2023 · 1 comment
Open

Accessing related child objects (deleted ones) #545

eddielu opened this issue Jul 13, 2023 · 1 comment

Comments

@eddielu
Copy link

eddielu commented Jul 13, 2023

I have an app with the following structure:

class Show(models.Model):
  name = models.CharField(max_length=255)

class ShowPerformer(models.Model):
  show = models.ForeignKey(Show, related_name="performers")
  name = models.CharField(max_length=255)

class ShowGuest(models.Model):
  show = models.ForeignKey(Show, related_name="guests")
  name = models.CharField(max_length=255)

but ShowPerformer's and ShowGuest's could be deleted at any time. I want to be able to see all previously related Performers and Guests LogEntry's from just a Show object, including LogEntry's which show performers and guests being deleted. Does anyone have any suggestions on how to accomplish this?

I saw this suggestion: #453, but should I make additional_data indexable for faster access? Otherwise, crawling through each LogEntry could be prohibitively slow when I want to see which performers and guests were deleted from a show's perspective.

Thanks so much!

@Ayobamidele
Copy link

You could write a boolean field for them called Active. and create a function under the performer and guest class called delete(), which when called only assigns a False value to Active.

Hope this could help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants