Question:
I am trying to follow this tutorial for using s3 but pretty much until the last step, somehow I get this error and I am not sure where I should import my own customed module
Tutorial link
https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/
Everything is fine, that I am able to upload / copy / use the static files using s3 then the step about creating custom storage for media usage
1 2 3 4 5 6 7 |
# custom_storages.py from django.conf import settings from storages.backends.s3boto import S3BotoStorage class StaticStorage(S3BotoStorage): location = settings.STATICFILES_LOCATION |
I created that .py
file inside the same directory as the setting.py (setting.py where it included INSTALLED_APPS
and more)
then inside the setting I added below as mentioned on the tutorial
1 2 3 4 |
STATICFILES_LOCATION = 'static' STATICFILES_STORAGE = 'custom_storages.StaticStorage' STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION) |
then I ran python manage.py collectstatic
I get this error
1 2 3 4 |
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) ImportError: No module named custom_storages |
Can someone give me a hand?
Thanks in advance.
Answer:
This credit should go to Shubham Namdeo who gave me the link of https://disqus.com/home/discussion/wwwcaktusblog/using_amazon_s3_to_store_your_django_sites_static_and_media_files/
well there are lots of suggestions and ways / errors people found which helps but as for me the part that helped me solve this problem is just move the custom_storage.py
into the same directory as the manage.py
so manage.py
and custom_storage.py
are actually in the same level of the directory structure then it all works just like that~
Don’t even need to import anything.
I have attached an image of the part where I got my answer so you don’t have to scroll all the way down if you have the same problem as mine.