1๐
So in your
user_file = models.FileField()
mention your upload_to directory. you can set this directory to the user id (for example).
So every user will have its own directory, and all the images and files will go to this directory.
Now in the case of accessing files. read the url.
for example: localhost.8000/1/file1.jpg
This 1 is userId and the folder name, upload_to value mentioned in models.
if this value is != userId (WRITE THIS CHECK IN VIEWS), return some error message else return the file.
๐คRanu Vijay
Source:stackexchange.com