I have the following relationship:
class Job(models.Model): .... class Task(models.Model): job = models.ForeignKey(Job) ....
Now, I have a Job
object with Task
objects tied to it, and I want to delete all the job's tasks.
From the documentation I understood that I can just use
Job.objects.get(pk=25).task_set.delete()
But for some reason, my task_set
object doesn't have a delete()
function:
*** AttributeError: 'RelatedManager' object has no attribute 'delete'
Any ideas?
Maybe do Job.objects.get(pk=25).task_set.all().delete()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With