1

I have a multi-user platform built using Django, Each user should have their own image gallery, which should be hidden to other users. How exactly can I design such a network using Django?

akajash
  • 97
  • 9
  • 1
    I think you can do it by filtering your model by user filed. For example ```Gallery.objects.filter(created_user=request.username)```. You must have a filed like this ```created_user``` in your model. – iliya May 30 '20 at 16:27

1 Answers1

1

I would say that it really depends how far you wish to go to separate users. If you just wish to save pictures and be sure that it is somehow noted to which user it belongs, than the approach in the comment by iliya would work - just add field to your model where you are storing your images that will link that image to user.

If you wish to separate this on disk too (for example, you wish to prepend username to url/path) than you need to do that - prepend username to filename, but you need to be sure that you do that on time. Be aware that this does not protect other users to view images belonging to other users if they know full path to the image.

If you wish to protect pictures between users (user can only see it's own pictures) you need to do a little bit more work. This post might help:

protecting user uploaded files django

Hope this helps (or at least gives you some ideas).

Branko Radojevic
  • 660
  • 1
  • 5
  • 14