title: Dynamic File Path in Django
body: <p>I'm trying to generate dynamic file paths in django. I want to make a file system like this:</p>
  
  <pre><code> -- user_12
       --- photo_1
       --- photo_2
   --- user_ 13
       ---- photo_1
  </code></pre>
  
  <p>I found a related question : <a href="https://stackoverflow.com/questions/4815150/django-custom-image-upload-field-with-dynamic-path">Django Custom image upload field with dynamic path</a></p>
  
  <p>Here, they say we can change the upload_to path and leads to <a href="https://docs.djangoproject.com/en/stable/topics/files/" rel="noreferrer">https://docs.djangoproject.com/en/stable/topics/files/</a> doc. In the documentation, there is an example :</p>
  
  <pre><code>from django.db import models
  from django.core.files.storage import FileSystemStorage
  
  fs = FileSystemStorage(location='/media/photos')
  
  class Car(models.Model):
      ...
      photo = models.ImageField(storage=fs)
  </code></pre>
  
  <p>But, still this is not dynamic, I want to give Car id to the image name, and I cant assign the id before Car definition completed. So how can I create a path with car ID ?? </p>