[Answered ]-Is there a way to ignore a query if it doesn't exist instead of getting an error?

2👍

You need to put exception handling in:

try:
    dancer = signedup.objects.get(pk=pk)
except signedup.DoesNotExist:
    # handle error

My answer will fix the exceptions your getting, but it looks like you’ve got some other issues with your code:

  • Why would your team_signup and signedup share a primary key?
  • Why do you try to delete both types of things at once?

You probably should be passing a single primary key (for the object being deleted) and the type of the object so you know what to delete from where.

Leave a comment