title: Unexpected behavior on delete of a model row
body: <p><strong>Situation:</strong></p>
  
  <p>I have two Model classes, in two different apps which are part of the same project. class doctor defined in appointments.models is a set of attributes associated with a doctor, like name, username, email, phone etc. class DoctorProfilePic is a Model defined in clinic.models, which has a StdImageField which stores images. doctor has a bidirectional mapping to DoctorProfilePic.</p>
  
  <pre><code>class doctor(models.Model):
      docid = models.AutoField(primary_key=True, unique=True) # Need autoincrement, unique and primary
      name = models.CharField(max_length=35)
      username = models.CharField(max_length=15)
      ...
      profilepic = models.ForeignKey(DoctorProfilePic, blank=True, null=True, on_delete=models.CASCADE)
      ...
  
  class DoctorProfilePic (models.Model):
      id = models.AutoField(primary_key=True, unique=True)
      name = models.CharField(max_length=255, blank=True)
      pic = StdImageField(upload_to="data/media/%Y/%m/%d", blank=True, variations={
          'large': (600, 400),
          'thumbnail': (150, 140, True),
          'medium': (300, 200),
      })
      doc = models.ForeignKey('appointments.doctor', blank=True,
                              null=True, on_delete=models.CASCADE)
  </code></pre>
  
  <p><strong>Anticipated response:</strong></p>
  
  <p>When user selects one of the profile pics from a selection box, and clicks Delete, django is supposed to delete the picture from the collection of pictures uploaded by the doctor.</p>
  
  <p><strong>Problem:</strong></p>
  
  <p>When the delete button is clicked, django deletes both the picture and the doctor, instead of just the former.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>def removeprofpic(request, docid):
      docid = int(docid)    
      if not IsOwnerorSuperUser(request, docid):
          return HttpResponse("You dont have permissions to do this.")
      doc = doctor.objects.get(docid = docid)
      if request.method == 'POST':
          print(request.POST)
          picid = int(request.POST.get('profilepic'))
          print(f'doc:{doc} picid:{picid}')
          pic = DoctorProfilePic.objects.get(doc = doc, id =picid)
          pic.delete()
          msg = f"Successfully removed profile picture."
      else:
          msg = "Not a valid POST"
      return HttpResponse(msg)
  </code></pre>
  
  <p>Now I'm guessing my problem is in defining the on_delete=models.CASCADE? Can someone explain what I've done wrong?</p>
  
  <p>Edit: What I need is, when a profile pic linked to a doctor is deleted, the doctor's pic be set to null(SETNULL?), but when a doctor is deleted, both doc and pic should be deleted(CASCADE?).</p>