What is the right way in Django to generate random URLs for user uploaded items?
What I usually do is create a dir with uploaded date as name, e.g. 04042018/ and then I rename the uploaded file with an uuid4, e.g. 550e8400-e29b-41d4-a716-446655440000.jpg
So the fullpath for the uploaded file will be something like this:
site_media/media/04042018/550e8400-e29b-41d4-a716-446655440000.jpg
Personally I think is best this way than having something with site_media/media/username/file.jpg because will be easier to figure out what images belong to who.
For example, uploading a gif to gfycat generates URLs in the form of Adjective-Adjective-Noun such as ForkedTestyRabbit.
Obviously going to this URL allows you to view the model instance that was uploaded.
So I'm thinking the post upload generates a unique random URL, e.g. /uploads/PurpleSmellyGiraffe. The model will have a column that is the custom URL part, i.e. PurpleSmellyGiraffe, and then in the urls.py we have anything /uploads/* will select the corresponding model with that URL. However, I'm not sure this is the best practice.
Could I get some feedback/suggestions on how to implement this?