title: DRF How to structure urls for photo sharing web app? (Structure/Best practice)
body: <p>Currently building backend API using Django Rest Framework for a group photo-sharing project.</p>
  <p>I'm trying to understand what's the best way to structure my API endpoints and I've encountered a problem (more like a question) for the best way to implement it.</p>
  <p>Here are my models:</p>
  <pre><code>class Photo(models.Model):
      uploader = models.ForeignKey(
          CustomUser, on_delete=models.CASCADE, related_name=&quot;photos&quot;
      )
      image = models.ImageField(upload_to=get_image_path)
      upload_date = models.DateField(auto_now_add=True, editable=False)
  
  
  class Collection(models.Model):
      name = models.CharField(max_length=255)
      description = models.CharField(max_length=500, blank=True)
      thumbnail = models.ImageField(blank=True)
      creator = models.ForeignKey(
          CustomUser, on_delete=models.CASCADE, related_name=&quot;created_collections&quot;
      )
      members = models.ManyToManyField(CustomUser, related_name=&quot;collections&quot;)
      photos = models.ManyToManyField(Photo, related_name=&quot;collections&quot;)
  </code></pre>
  <p>Basically each user can create a Collection model which holds different photos he can share with others and they can upload too.</p>
  <p>The endpoints I have right now are the basic ViewSet ones:</p>
  <p>Photo:</p>
  <blockquote>
  <p>/api/photo GET/POST</p>
  <p>/api/photo/id GET/DELETE/PATCH</p>
  </blockquote>
  <p>Collection:</p>
  <blockquote>
  <p>/api/collection GET/POST</p>
  <p>/api/collection/id GET/DELETE/PATCH</p>
  </blockquote>
  <p><strong>My question is:
  What should be the endpoint for a user to add a photo to a collection? (the best way to implement it)</strong></p>
  <p><strong>I've thought of a few options which are:</strong></p>
  <p>1.POST request to /api/collection/id containing the ID of the photo I want to add.</p>
  <p>2.POST request to /api/photo/id containing the ID of the collection I want to add the photo to.</p>
  <p>3.Using a PATCH method maybe? (Don't know if that would be better)</p>
  <p>I am trying to understand what would be the best REST practice in this case.</p>
  <p>Let me know if you need to see more code,
  Thanks!</p>
  <p>Link to the git: <a href="https://github.com/davidplo4545/JustShare.git" rel="nofollow noreferrer">https://github.com/davidplo4545/JustShare.git</a></p>