简体   繁体   English

生产环境下 Django 的媒体文件存放在哪里?

[英]Where to store media file of Django on production?

So I am learning Django. And I have made some websites with it.所以我正在学习 Django。我用它做了一些网站。 Now I am hosting those to Heroku. I am using free Dyno on Heroku .现在我将这些托管到 Heroku。我在Heroku上使用免费的 Dyno。 Also, I am using supabase.io database instead of Heroku's because supabase gives more space for the database on the free tier.另外,我使用的是supabase.io数据库而不是 Heroku,因为supabase在免费层为数据库提供了更多空间。 Now the problem I am facing is with the media files.现在我面临的问题是媒体文件。 I can not access them on Heroku since I don't have any place to store them.我无法在Heroku上访问它们,因为我没有任何地方可以存储它们。

I have seen some addons on Heroku for the file storage but to use those I need to provide my credit card information, which I do not have.我在Heroku上看到了一些用于文件存储的插件,但要使用这些插件,我需要提供我的信用卡信息,而我没有。

But I have seen an object storage option on supabase.io .但是我在 supabase.io 上看到了一个supabase.io存储选项。 It gives 1 GB free storage which is more than enough for me now.它提供 1 GB 的免费存储空间,这对我来说已经足够了。 But I don't know how can I use it with my Django application.但我不知道如何将它与我的 Django 应用程序一起使用。 That is why I am looking for help.这就是我寻求帮助的原因。 Also if there are any free alternatives to store my media file without credit card information, please feel free to guide me.此外,如果有任何免费的替代方案来存储我的没有信用卡信息的媒体文件,请随时指导我。 Since I do not own any card.因为我没有任何卡。

There is a community-supported Python library for Supabase that has support for Supabase Storage, which you can try: Supabase 有一个社区支持的 Python 库,它支持 Supabase Storage,您可以尝试:

https://github.com/supabase-community/supabase-py https://github.com/supabase-community/supabase-py

see the storage code here:在此处查看存储代码:

https://github.com/supabase-community/supabase-py/tree/develop/supabase/lib/storage https://github.com/supabase-community/supabase-py/tree/develop/supabase/lib/storage

I know this might be an old question, but for future reference, you could probably try out django-cloudinary-storage .我知道这可能是一个老问题,但为了将来参考,您可以试试django-cloudinary-storage You can take a look at this answer here .您可以在此处查看此答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM