1

I am working on building a django based blog-like site, it currently has one app. It contains a media folder which contains the images uploaded by the user. However, the MEDIA_URL and MEDIA_ROOT are specified in the main settings.py file.

But in the future, there will be more apps containing more media, thus I want separate MEDIA_URL(s) and settings for each app.

I tried writing the MEDIA_ROOT and MEDIA_URL separately in the apps.py file, but removing this from the main settings.py file results in an error.

I also tried using FileSystemStorage, but even this needed me to have a MEDIA_URLS in the settings.py file.

Please let me know if you need any more details. Any help is appreciated, thanks.

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39

1 Answers1

1

Maybe, you can use different folders inside MEDIA_ROOT for different models. For example:

class MyModel(models.Model):
    file = models.FileField(upload_to='my_model')

When you upload a new file via MyModel admin, in MEDIA folder a folder with the name my_model will be created and the uploaded file will be there.

shoytov
  • 585
  • 4
  • 10