New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requirements #6
Comments
Ah so I'm publishing to pypi under django-storages-redux. I haven't released version 1.2.0 which will be the first with python3 (3.3+) support because while the tests all pass and I am confident that it will work I'd like to actually try it out on a real server pushing to S3 which is something I will be doing tonight on a personal project. I'll be sure to ping you here when I do publish and will leave this issue open until then. Also, if you want to install from git in general with pip this reddit post shows you how to do it. |
Thank-you very much for taking this upon yourself! Great community spirit! FWIW, I deployed a website last night (edit: GMT) using the code from master, and it worked fantastically. The only issue I noticed was a warning generated during That's installing on |
@meshy great to see it worked for you! Could you please provide more details about your setup? I've followed this post (https://ashokfernandez.wordpress.com/2014/03/11/deploying-a-django-app-to-amazon-aws-with-nginx-gunicorn-git/) when creating my project and this lead me to have this at settings:
Also, I have 'boto' e 'django-storages-redux' as requirements installed. Unfortunatelly I'm having an error that ends with
What am I missing here? |
Sure I had to install the (as yet) unreleased version, as the python 3 fixes for the s3boto backend are not included with version pip install -e 'git+https://github.com/jschneier/django-storages-redux.git#egg=django-storages-redux' I then added some code to put static and client media in separate folders in the same bucket: #core/storage.py
from storages.backends.s3boto import S3BotoStorage
class StaticRootS3BotoStorage(S3BotoStorage):
location = 'static'
class MediaRootS3BotoStorage(S3BotoStorage):
location = 'client'
# core/settings.py
INSTALLED_APPS += ('storages',)
STATIC_ROOT = os.path.join(BASE_DIR, 'static_media')
MEDIA_ROOT = os.path.join(BASE_DIR, 'client_media')
STATICFILES_DIR = os.path.join(BASE_DIR, 'core/static')
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME')
S3_URL = 'http://{0}.s3.amazonaws.com/'.format(AWS_STORAGE_BUCKET_NAME)
STATIC_URL = os.environ.get('STATIC_URL', S3_URL + 'static/')
DEFAULT_FILE_STORAGE = os.environ.get(
'DEFAULT_FILE_STORAGE',
'core.storage.MediaRootS3BotoStorage',
)
STATICFILES_STORAGE = os.environ.get(
'STATICFILES_STORAGE',
'core.storage.StaticRootS3BotoStorage',
)
MEDIA_URL = os.environ.get('MEDIA_URL', S3_URL + 'media/') You'll note that I make a lot of use of environment variables. It's defaulting to production values. In dev, I use: DEFAULT_FILE_STORAGE='django.core.files.storage.FileSystemStorage' \
STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage' \
STATIC_URL='/static/' \
MEDIA_URL='/client/' \
DEBUG=1 \
python manage.py runserver To get the static media onto s3, I ran I hope that's enough for you to get it going |
@meshy great explanation! I will probably steal some of that for when I update the docs if that's okay with you. Just released 1.2 so I'm going to close this issue now. |
Thanks
Fantastic, thanks! |
@meshy @jschneier It's working!! Thanks a lot guys! I was struggling with this problem for a long time 😄 |
@meshy thanks for the work. Its a clear cut explanation. I think there is a typo when you mention MEDIA_URL = os.environ.get('MEDIA_URL', S3_URL + 'media/') I think it should be MEDIA_URL = os.environ.get('MEDIA_URL', S3_URL + 'client/') |
@santhu221633 I think that's just a personal preference for the location of the client media. |
You're right though, it's not very consistent! |
@meshy I am trying replicate your configuration, and I have the following question if you let me please: In the and
What is the value of the I have the following scheme based in your schema configuration:
But, when I run collectstatics, my files always go to My apologies for the question |
I managed to resolve the same issue just using the following parameters:
I changed https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html |
Great project!
I've been following django-storages for a while facing the same python3 incompatibility problem. Good to see someone is taking care of the project!
I'm quite new to django, so the answer may be simple: what should I use as requirement? I mean, I need to point to this github repo?
Maybe this is a commom question that may be answered in the README file ;)
Thanks a lot!!
The text was updated successfully, but these errors were encountered: