Learn Django - Implementing AWS S3 Storage for Static and Media files in Django

Поділитися
Вставка
  • Опубліковано 15 вер 2024

КОМЕНТАРІ • 75

  • @hadesunseen6388
    @hadesunseen6388 Рік тому +3

    thank you for this wonderful tutorial. successfully deployed static files to s3

  • @josephc3080
    @josephc3080 3 роки тому +3

    Thank you for actually explaining the process of setting up policies rather than just leaving the user with a completely unsecured bucket.

  • @bernardlaughlin2718
    @bernardlaughlin2718 3 роки тому +2

    THANK YOU SO MUCH! I spent the last 12 hours trying to get S3 to host my static files and media. Finally got everything working after watching your video.

  • @luiszaragoza969
    @luiszaragoza969 Рік тому

    Beautiful - I was able to deploy my static files on the AWS S3 service right away. Thank you for taking the time to create this video, it was very helpful!

  • @gyanookharel7440
    @gyanookharel7440 3 роки тому +12

    ""If permission is denied, delete the bucket and create a new one. I promise that's the case. "" -- My man, I bet my life that was the case.

  • @roblockhart890
    @roblockhart890 2 роки тому

    Thank You!!! AWS a moving target as it evolves thru time.. This is an excellent tutorial covering your first encounter with S3 - as at least currently (13 Apr 2022). Even now though I have some doubts about the 'pulic-read' settings. I found that did not work as ACL was disabled. Setting it to 'none' works. Not sure about the security implications of that though as I would like to set the policy explicitly rather than relying on S2's default. That aside, excellent intro to securing your server via setting app-specific Group/User access. Superb work my friend. Appreciated.

  • @李晧暐
    @李晧暐 3 роки тому +4

    OMG YOUR CHANNEL IS SO AWESOME!!
    You explain everything so well and so clearfully!!!
    Thank you so much!!!
    Hopefully to see more video on your channel!!
    and could you explain more about setting aws s3 acl?

  • @EUU100
    @EUU100 3 роки тому +1

    Thank you, so clear and easy to follow. I also finally understand staticfiles and mediafiles and the whole saving process a lot more now, thank you i appreciate it

    • @EUU100
      @EUU100 3 роки тому +1

      after following along with this successfully, what would your advice be for deployment to production? I would like to make a portfolio website i have been working on with Django live, i ask because i have seen you go through various methods on your channel. Thanks in advance

    • @veryacademy
      @veryacademy  3 роки тому

      Not much to say really for a portfolio website, just keep it simple and easy to manage/update. It might serve its purpose very quickly and get you where you want it to - not knowing what the portfolio website is going to be used for - sorry I assume it is to help you get a job.

  • @ndifrekeumoren3548
    @ndifrekeumoren3548 4 роки тому +1

    Very concise tutorial! Thanks for this tutorial

  • @norby1128
    @norby1128 3 роки тому +1

    Thank you!, very well explained, It helps me a lot.

  • @koksalkapucuoglu
    @koksalkapucuoglu 3 роки тому +1

    It's very helpful, thank you so much.

    • @veryacademy
      @veryacademy  3 роки тому +1

      Glad it was helpful! I have another S3 with Docker container and Heroku on Monday coming out

  • @nilupulmanodya
    @nilupulmanodya 3 роки тому +1

    Thanks Bro.. you saved my time

  • @shakirazim
    @shakirazim 4 роки тому

    It was very much helpful... Thnx a lot Sir 👍🔥

  • @helixaros
    @helixaros Рік тому +1

    Hi there, thank you for all the videos, you are the go to option for anything related to Django.
    Do you happen to have a video about encrypting files on AWS (S3) ?

  • @natbibi
    @natbibi 3 роки тому

    Thank you, super helpful and and easy to follow!

  • @asadbekmuxtorov1283
    @asadbekmuxtorov1283 Рік тому +1

    Raxmat

  • @narattamsutradhar
    @narattamsutradhar 3 роки тому +1

    Thank you sir usefull video

  • @edchelstephens
    @edchelstephens 2 роки тому

    Thank you!

  • @KrishnaManohar8021
    @KrishnaManohar8021 4 роки тому +1

    Try to include:
    1. How can we handle log files(forint end & back-end) in AWS
    2. How can we Handel sessions (after 15mts automatically logout like that)

    • @veryacademy
      @veryacademy  4 роки тому +1

      All great suggestions - thank you!

  • @shawnlentz6590
    @shawnlentz6590 3 роки тому +1

    How do you actually access the media files when using AWS? I've got it all set up like this, static and media both upload to the bucket correctly, and static files can be accessed properly (Like: {% static 'staticfile' %} works correctly), but media files still try and access the local files instead of the S3 bucket.

  • @ayuzawamisaki239
    @ayuzawamisaki239 2 роки тому

    botocore.exceptions.ClientError: An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs i got this error any idea ??

  • @Jack-oi8gn
    @Jack-oi8gn Рік тому

    Should we leave the MEDIA_ROOT like that?

  • @t-distributedkid3825
    @t-distributedkid3825 2 роки тому +1

    I got permission denied for upload --- Tried deleting the bucket and recreating didnot work
    Finally I unchecked the option ACLs disabled (recommended) thought it was not recommended
    It worked!! I neeed to find a another solution

    • @veryacademy
      @veryacademy  2 роки тому

      Have a read see if this helps you django-storages.readthedocs.io/en/latest/backends/amazon-S3.html

  • @dipsy7159
    @dipsy7159 3 роки тому +1

    What if I only want to upload media files to s3 not the static files (since I have upload my static files using whitenoise)
    (When I followed the tutorial, my bootstrap end up not working)

    • @veryacademy
      @veryacademy  3 роки тому +1

      Hi Dipsy, if you don't want to include static change the settings.py file so that static files are not included in s3. Regarding bootstrap - this tutorial is using bootstrap 4 not 5 if that is the problem. Also put the JS is the header of the page - that could solve it.

  • @keanemafika2290
    @keanemafika2290 3 роки тому +1

    Hello Very. I am getting this error when i go to inspect source and try to open one of the css files:
    IllegalLocationConstraintException: The af-south-1 location constraint is incompatible for the region specific endpoint this request was sent to.
    Please assist

    • @veryacademy
      @veryacademy  3 роки тому

      github.com/boto/boto3/issues/2622

    • @keanemafika2290
      @keanemafika2290 3 роки тому

      @@veryacademy Thank you Very much, I was able to solve that issue from that article.
      Your work is really really helpful, yes, even in the Jungles of Zimbabwe lol😂

  • @garethjones3860
    @garethjones3860 3 роки тому +1

    I have hooked in S3 and serving my media files back into my application so users can click a button to view the document or documents they have uploaded.
    How can I mask the url so it’s not showing the access key and also how can you tie down the url so it can only be accessed when a user is logged into the system and not just a free url someone can send to anyone?
    Any help or direction is much appreciated
    Gareth

    • @veryacademy
      @veryacademy  3 роки тому

      Much of the S3 security is done through permissions. Have a look at this to see if it helps
      stackoverflow.com/questions/54704669/how-to-hide-aws-s3-bucket-url-with-custom-cname

    • @garethjones3860
      @garethjones3860 3 роки тому

      @@veryacademy thank you, unfortunately doesn’t mean a lot to me at the moment :-) but will keep researching 🧐, keep up the great work

  • @dlfp125
    @dlfp125 4 роки тому +1

    I want to delete folder when file is saved in S3. remove foloder "media"
    def user_directory_path(instance, filename):
    return '{0}'.format(filename)

    • @veryacademy
      @veryacademy  3 роки тому

      Hello, sorry my friend - when do you want to delete folder?

  • @rinshinjalal1952
    @rinshinjalal1952 3 роки тому +2

    I have build websites with django and react but don't know how much price I want to ask for it pls help can you make a video about dynamic website pricing 🥺🥺🥺

    • @veryacademy
      @veryacademy  3 роки тому

      Been thinking about this today. Maybe. It is tricky, their are lots of variables here.

  • @aditmodi
    @aditmodi 3 роки тому +1

    great tutorial. I wanted a file storage application that is set up on my domain and it can view , add , delete files ( can be files / folders / images / audio ) any sources/ materials on how I can do that ???

    • @veryacademy
      @veryacademy  3 роки тому

      You mean you want a CRUD type admin system for S3 files for your app?

    • @aditmodi
      @aditmodi 3 роки тому

      @@veryacademy sort of. I want to explore how to create such a system. can you help me with that.

  • @jackiechann3689
    @jackiechann3689 3 роки тому +1

    I upload with different approach but i have 2 websites one of them is give error access dennied

    • @veryacademy
      @veryacademy  3 роки тому +1

      Strange one - sorry I cant really assist you - hope you get it sorted 👍

  • @pranatis2314
    @pranatis2314 3 роки тому +1

    Can we call the images via ajax from S3 bucket??

  • @alimiadam578
    @alimiadam578 4 роки тому

    Hello sir please im getting this error:Partial credentials found in explicit, missing: aws_secrect_access_key. And i have put in the secrect key as required

    • @veryacademy
      @veryacademy  4 роки тому

      Sorry for the delay - that I am afraid is difficult to suggest an answer. I is very explicit - missing key so there must be something up with that - maybe a typo somewhere in the code stopping it from reading that line - let me know if you fix it

  • @maahad767
    @maahad767 3 роки тому

    If I am not wrong, I think Django doesn't allow to serve static files being served locally in production mode?

    • @veryacademy
      @veryacademy  3 роки тому +1

      whitenoise.evans.io/en/legacy-2.x/django.html WhiteNoise will now serve your static files

    • @maahad767
      @maahad767 3 роки тому

      @@veryacademy Thanks. I was struggling with serving static files locally as well as s3. I solved it by learning about private and public read parts in more dept from you. Thanks for letting me know that I can use whitenoise as well for serving static files. I've seen people using that, but I didn't know why(didn't want to know as well). I think django-heroku module also has some settings to serve static files locally. Thank you so much.

  • @musicord3132
    @musicord3132 2 роки тому

    hey can you make a video with azure.

  • @JitenderKumar-fs2xv
    @JitenderKumar-fs2xv 4 роки тому

    Sir can you tell me what we have to do when we go on production. What are the changes required ??

    • @veryacademy
      @veryacademy  4 роки тому +1

      Hi Jitender, sorry - I should have gone into more detail at the time. First and foremost just make sure you don't use your keys in your settings file. Save your environment variables into a .env file in your project folder. help.pythonanywhere.com/pages/environment-variables-for-web-apps/
      From that point you just need to ensure that you have the right permissions for your files/folders. I will try and get back to this in the near future and give more information to support deployment.

    • @JitenderKumar-fs2xv
      @JitenderKumar-fs2xv 4 роки тому

      @@veryacademy I am waiting for that notification.

  • @seesamsaw
    @seesamsaw 3 роки тому

    My static files are being hosted, but not my media files. Very frustrating as I've quadruple-checked my settings and played around with different things. On to the next tutorial...

    • @veryacademy
      @veryacademy  3 роки тому

      Strange one. Difficult here to give you an answer - I would first setup with just media files locally - then apply that only - backward engineer if you are not familiar

  • @KrishnaManohar8021
    @KrishnaManohar8021 4 роки тому

    🔥🔥🔥🔥🔥🔥

    • @veryacademy
      @veryacademy  4 роки тому +1

      Thanks - am on a mission today - hopefully 3/4 more to come today! Next Celery today - then Testing tomorrow.

    • @KrishnaManohar8021
      @KrishnaManohar8021 4 роки тому

      @@veryacademy wow.... great 👍

  • @paborlouise319
    @paborlouise319 4 роки тому

    Sweet

    • @veryacademy
      @veryacademy  4 роки тому

      Let me know when you are ready for the deploy to Heroku. I will follow up this tutorial. For example you really dont want to keep the API keys in the settings file. We can sure things up later though, just have a play with it.

    • @paborlouise319
      @paborlouise319 4 роки тому

      @@veryacademy exactly. Thanks sir. But I'm not gonna do this for now, until am done with the project.