Implement Amazon S3 Storage for Static and Media files in Django

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 106

  • @andersonlontsi299
    @andersonlontsi299 7 месяцев назад +3

    I HIGHLY RECOMMEND this video. I just followed the video, followed the steps and it's working perfectly well. Big THANK YOU sir.

    • @CloudWithDjango
      @CloudWithDjango  7 месяцев назад +2

      Thank you so much for your kind words. I really appreciate it! Of course, it's my pleasure! :)

  • @svysvr4268
    @svysvr4268 2 месяца назад

    You did it, Buddy!!!! Thanks for hard work and clear presentation of the ENTIRE process.

    • @CloudWithDjango
      @CloudWithDjango  2 месяца назад

      Thank you so much! Of course, my pleasure! I'm glad that you enjoyed the video!

  • @ARYANKUMAR-gz2qw
    @ARYANKUMAR-gz2qw 4 дня назад

    You are awsome !!! Thanks for this wonderful tutorial, It worked straight!

    • @CloudWithDjango
      @CloudWithDjango  4 дня назад

      Thank you so much for your kind words and feedback! Of course, my pleasure! I'm glad that it worked!

  • @dillymccaffrey
    @dillymccaffrey 9 месяцев назад +1

    Great video! Clearly showed every step and easy to understand. Thank You :)

    • @CloudWithDjango
      @CloudWithDjango  9 месяцев назад

      Thank you so much! I'm glad that you found it useful!

  • @frhadagayev8193
    @frhadagayev8193 11 месяцев назад

    Thank you for the video. It took my whole day to solve it and finally with your video I did it

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад +1

      My pleasure! I'm very glad to hear that you managed to come right with what you were trying to solve! All the best to you!

  • @the_60_second_chill
    @the_60_second_chill 5 месяцев назад

    the last minutes are treasure

  • @staslis1924
    @staslis1924 Год назад

    Awesome, thank you very much for this detailed AWS video!

  • @Rex-fm2nt
    @Rex-fm2nt 6 месяцев назад

    new subscriber because YOU ARE AWESOME!!! keep making these amazing tutorials!

  • @aashishchoudhary7506
    @aashishchoudhary7506 19 дней назад +1

    Everything works in local environment but doesn't work in production (ec2 deployed)

    • @CloudWithDjango
      @CloudWithDjango  18 дней назад

      Hi. This process works in both environments. The only thing that you need to set in production environments is your environment variables. As soon as that's configured it will work anywhere.
      I'd suggest double checking the process.

  • @ab232xsss23
    @ab232xsss23 4 месяца назад

    Great video, thanks !

  • @jeromekm4479
    @jeromekm4479 29 дней назад +1

    Simply Wowwwwwwwwwwwwwww

  • @emanuelcamargo3698
    @emanuelcamargo3698 3 месяца назад

    i Can't say thank you enough

    • @CloudWithDjango
      @CloudWithDjango  3 месяца назад

      Of course, my pleasure! Glad that you liked the video! :)

  • @skahler
    @skahler 3 месяца назад +2

    I've done literally everything and even double checked my settings with GPT. I can't for the life of me get this to work and I've been at it all day. It keeps defaulting to static, it's like it's not even trying to push to S3 even though all the credentials are set up and everything, storages is in the middleware, whitenoise is commented out, and static files storage is boto. I have no idea what to do. It should at least throw an error if something is wrong with permmissions, or there should be a way to see if there was even a request made to s3. Oh. My. Gosh. It's been 24 hours, possibly 6-8 hours at just this alone.

    • @CloudWithDjango
      @CloudWithDjango  Месяц назад

      Hi there. I'd suggest taking a look at the source code provided and using that as a baseline. I've re-tested the process and everything works as it should. Please ensure that you double-check your AWS_STORAGE_BUCKET_NAME, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_S3_REGION_NAME are set correctly. That you haven't changed their names and that there are no additional spaces. Look for any potential conflicts or overriding of your S3 settings, especially STATIC_URL and STATIC_ROOT. Ensure whitenoise is completely removed and not somehow reactivated elsewhere in the config. Additionally, please ensure that you have no network restrictions on firewalls preventing communication between Django and Amazon S3 via the CLI.
      Good luck!

  • @nigh6374
    @nigh6374 9 месяцев назад

    OMG this was amazingggggg

  • @defendersart3051
    @defendersart3051 11 месяцев назад

    Does getObject handle post request too.. I mean,
    form submission kind of work or adding users in our website.
    In short,
    Read/Write both permission works through GetObject in s3 bucket?

  • @KumarSahil78
    @KumarSahil78 Год назад

    Amazing video

  • @ajibadeyakubadebare2169
    @ajibadeyakubadebare2169 11 месяцев назад

    Thank you so much for this tutorials. I have a question please
    Does EC2 instances come with storage?

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад

      My pleasure!
      Yes, EC2 instances come with storage. They are grouped into two types. Namely:
      Instance Store Volumes (Ephemeral Storage) and Amazon Elastic Block Store (EBS):

    • @ajibadeyakubadebare2169
      @ajibadeyakubadebare2169 11 месяцев назад

      @@CloudWithDjango Thank you

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад

      My pleasure!

  • @usmanghani9941
    @usmanghani9941 Месяц назад

    I had configured all my code according to your but still facing an error the module not found: storages, and I have confirmed that the module is correctly installed in my env. Can you help me in this situation?

    • @CloudWithDjango
      @CloudWithDjango  Месяц назад

      Hi. Kindly refer to the source code in the github link (in the description). This code has been tried and tested all you need to do is install the necessary packages, follow the steps and you will be fine. I'd suggest using that as a baseline first for your first application. Good luck!

  • @NicolastheThird-h6m
    @NicolastheThird-h6m Год назад

    Can you do a video on Customizing Django allauth templates.

  • @marklong2060
    @marklong2060 7 месяцев назад

    I am using Django 5.0, django-storages 1.14.2 and boto3 1.34.73. I have been trying all weekend to get this app to work with Backblaze B2 or Digital Ocean Spaces. Both are said to be S3 compatable. I am running into the same issue with both. My /static/ directory does not get picked up and loaded into my storage bucket upon calling collectstatic. Everything pertaining to my admin and all of the other apps in the project that have static files get swept up and loaded into my storage bucket and the admin works fine...but no static files or media files for my front end. I have no idea if it is django-storages or Django or something else. My logs look fine except for the fact that they do not show my /static/ directory being swept up for my remote bucket. Everything works fine in dev environment when serving from the file system.

    • @CloudWithDjango
      @CloudWithDjango  7 месяцев назад +1

      Hi, to troubleshoot the issue with your Django application not loading static files into your remote storage bucket:
      First, ensure that your Django settings are correctly configured to use the remote storage backend for static files. Check your STATIC_URL, STATIC_ROOT, and STATICFILES_STORAGE settings in your settings.py file. Verify that your application has the necessary permissions to write to the remote storage backend, including both reading and writing permissions for static files. Check the bucket settings in Backblaze B2 or Digital Ocean Spaces to confirm that they allow access and write permissions for your Django application. Test connectivity by manually uploading a static file to your remote storage backend using the provider's tools. This can help confirm that your application can connect to the storage backend successfully. Review Django logs for any error messages or warnings related to static file handling. This can provide clues to the underlying issue. By following these steps, you should be able to identify and resolve the issue with loading static files into your remote storage bucket.
      As a final resort, I'd suggest downloading and utilising the final project source code that was used for this video. It is available in the description (for clarity).
      Good luck!

    • @gofooddy5472
      @gofooddy5472 5 месяцев назад +1

      @marklong2060 Were you able to solve it?

    • @marklong2060
      @marklong2060 5 месяцев назад

      @@gofooddy5472 no I wasn't able to make it work. I resorted to storing the images to hard disk for now. For this particular app it works okay because its low traffic etc. Will need to revisit this issue later for sure.

  • @siddharth.chandani
    @siddharth.chandani 7 месяцев назад

    Hello Just wanted to ask a question which service should i choose in AWS.. Elastic Beanstalk or S3 ? (please recommend the free one)

    • @CloudWithDjango
      @CloudWithDjango  7 месяцев назад

      Hi,
      Unfortunately, there are no free services in AWS. You will pay a fee.
      Elastic Beanstalk is for deployment and S3 is for handling objects (file management). The services are different.

  • @raulelizaldebreton9142
    @raulelizaldebreton9142 8 месяцев назад

    How can i solve this error: botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden

    • @CloudWithDjango
      @CloudWithDjango  8 месяцев назад

      Hi,
      Please ensure that you have no syntax errors with the variable declaration and that you have valid access keys that you are using. This is the main reasons for error.

  • @o-1352
    @o-1352 8 месяцев назад

    Hi, thanks for the tutorial but should I follow the same steps if I have a deployed app in EC2?

    • @CloudWithDjango
      @CloudWithDjango  8 месяцев назад

      Hi,
      No worries!
      It would be easier to follow these steps before deployment. It could be done with an app already deployed although, it might be tricky to handle from that approach

    • @o-1352
      @o-1352 8 месяцев назад

      @@CloudWithDjangothanks, a few changes but it worked

    • @CloudWithDjango
      @CloudWithDjango  8 месяцев назад

      No worries! Glad that you managed in the end!

  • @faizkhan2861
    @faizkhan2861 10 месяцев назад

    How do i connect this to my django website which is deployed using pythonanywhere by watching ur other video? Since my css and js doesn't work there

    • @CloudWithDjango
      @CloudWithDjango  10 месяцев назад

      Hi,
      As soon as you've completed Amazon S3 for static and media files. It should work fine on PythonAnywhere. You need to do S3 first and then PythonAnywhere.

  • @nigh6374
    @nigh6374 9 месяцев назад

    Guys, I have a problem, it worked properly, but I'm using tailwind with django, and that's why when I activate the bucket my css file also goes to s3, and is not reloaded on the page, I already deleted my tailwind css from the bucket but it didn't solve it, I only solve it by removing amazon s3 from the settings. Does anyone know how to solve it?

    • @CloudWithDjango
      @CloudWithDjango  8 месяцев назад

      Hi,
      Please ensure your static files are correctly configured to be served from Amazon S3. Check STATIC_URL and STATICFILES_STORAGE settings. Verify CSS files generated by Tailwind are collected and stored in your static files directory, then uploaded to S3. If CSS files aren't updating, check caching settings and invalidate cache when deploying changes. If issues persist, consult documentation or forums for specific guidance.
      Good luck!

  • @kareemal-khayat3105
    @kareemal-khayat3105 5 месяцев назад

    the media files now is public .. how to prevent that? i have some media files that only the staff users can access it !

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад

      Hi. Yes, that's right and how we go about it in this video, and under the assumption that they are like profile pictures and for everyone to see which everyone should see. If you only want staff users to access it, you will need to integrate additional settings to your JSON policy on S3

  • @OasisFinder
    @OasisFinder 11 месяцев назад

    i have creates AWS account, websites ask me about my credit card details , and i choose free account tier out of 3 options.
    i need to know is this process free or i need to pay ?

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад

      Hi,
      Please kindly read the article link guide for more insight.

  • @WhiteFontStudios
    @WhiteFontStudios 9 месяцев назад

    you need to go through all of this just to render css and js files in your deployed django app??

    • @CloudWithDjango
      @CloudWithDjango  9 месяцев назад

      Hi,
      Also, media files, but yes it is a long process with Amazon S3.

  • @pranavbakare8922
    @pranavbakare8922 4 месяца назад

    How much time it will take for collect static command over aws????

    • @CloudWithDjango
      @CloudWithDjango  4 месяца назад

      Hi. I cannot say. It all depends on the size of your application with the AWS CLI.

    • @pranavbakare8922
      @pranavbakare8922 4 месяца назад

      @@CloudWithDjango As check I was using ck editor for text body so it's consuming more time and files.... Post removal of ck editor it's working smoothly...
      .Thank you for contribution.... Keep sharing

    • @CloudWithDjango
      @CloudWithDjango  3 месяца назад

      No worries! Glad that it helped!

  • @SyedIbrahim-77
    @SyedIbrahim-77 11 месяцев назад

    Is making a policy a necessary step? Because I watched some other tutorials and they did not create a S3 bucket policy

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад +1

      Hi,
      Yes, it is necessary so that we can ensure that our bucket is public and the API action that we can perform upon our objects. Sure, you can upload objects without the policy, but you still need to be able to access it. This is why we use the policy.

    • @syedibrahim7894
      @syedibrahim7894 11 месяцев назад

      Okay, thank you so much! Excellent video btw :')

    • @CloudWithDjango
      @CloudWithDjango  11 месяцев назад

      My pleasure! I'm glad that you enjoyed the video, thank you! :)

  • @extorrote
    @extorrote 5 месяцев назад

    So after all this people can use my webApp online? How do I configure the link so people can go online and use my app ? Thank you

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад +1

      Hi,
      I think there is a misunderstanding. In web development static files need to be public as do images if it's publically for all.
      This is not a deployment video, so you'd need to watch a tutorial on deployment so people can go online and use your app

    • @extorrote
      @extorrote 5 месяцев назад

      Thank you for your response , it’s my first time hosting a website or webApp, now my bucket got created in [us-1] and thats not letting me use the collectstatic

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад +1

      No problem. I'd recommend double checking your steps and ensuring that everything is exact as I have done. It will work

    • @extorrote
      @extorrote 5 месяцев назад

      @@CloudWithDjango I’ll try again , thank you !

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад +1

      Good luck! Of course, my pleasure!

  • @toddgilbey3979
    @toddgilbey3979 5 месяцев назад

    Unknown Error
    An unexpected error occurred.
    API response
    The specified configuration does not exist.
    Helpful.....

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад +1

      Hi,
      I included the GitHub source code in the description, maybe check this for further reference?

    • @toddgilbey3979
      @toddgilbey3979 5 месяцев назад

      @@CloudWithDjango Thank you, will have a look.

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад

      My pleasure! Good luck!

  • @jonatanmsanchez
    @jonatanmsanchez 5 месяцев назад

    It helps but when I do the push in GitHub, does not allow me to, because of the keys 😢what can I do?

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад

      Hi,
      This won't work because the access keys are sensitive data and it's dangerous to upload a project with aws access leys exposed. It should be within environment variables.

    • @jonatanmsanchez
      @jonatanmsanchez 5 месяцев назад

      @@CloudWithDjango I might need s tutorial for that as well ❤️‍🩹

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад

      Sure thing! I have a few tutorials on the channel that focus on setting up environment variables

    • @jonatanmsanchez
      @jonatanmsanchez 5 месяцев назад

      @@CloudWithDjango thank you, I'll look it up

    • @CloudWithDjango
      @CloudWithDjango  5 месяцев назад

      No problem! Good luck!

  • @durgamokshitha333
    @durgamokshitha333 Год назад

    Can this process also be used for Django Rest Framework API ?

    • @CloudWithDjango
      @CloudWithDjango  Год назад

      Hi,
      The best way to know would be to test it and see

    • @durgamokshitha333
      @durgamokshitha333 Год назад

      @@CloudWithDjango
      Thanks for the reply. I have another question.
      Django Rest Framework API and Nextjs combination Is this process the same or different?

    • @CloudWithDjango
      @CloudWithDjango  Год назад +1

      My pleasure!
      The process of combining Django Rest Framework (DRF) API with Next.js is similar to integrating any frontend framework with a backend API. You would use Next.js to create the frontend, and DRF to develop the backend API. The communication between them typically involves making HTTP requests from Next.js to the DRF endpoints. However, the specific implementation details may vary based on your project requirements and architecture choices. Ensure proper CORS (Cross-Origin Resource Sharing) settings, handle authentication, and manage state as needed in your Next.js application.

    • @durgamokshitha333
      @durgamokshitha333 Год назад

      @@CloudWithDjangook thank you

    • @CloudWithDjango
      @CloudWithDjango  Год назад

      My pleasure!

  • @anthonydattolo6297
    @anthonydattolo6297 7 месяцев назад

    no CDN setup?

  • @Haziq-t6h
    @Haziq-t6h 6 месяцев назад

    hi why am i getting this error when doing 'manage.py collectstatic'. ..... raise ImproperlyConfigured("Could not load Boto3's S3 bindings. %s" % e)
    django.core.exceptions.ImproperlyConfigured: Could not load Boto3's S3 bindings. No module named 'six.moves' ...... i do have six package installed

    • @CloudWithDjango
      @CloudWithDjango  6 месяцев назад

      Hi,
      I'd suggest that you double check your configuration settings and that there are no syntax issues.

  • @maxsll3372
    @maxsll3372 9 месяцев назад

    its paid !!

    • @CloudWithDjango
      @CloudWithDjango  9 месяцев назад

      Hi,
      Yes, Amazon S3 is paid depending on your usage limit

  • @learnwithkilter3432
    @learnwithkilter3432 Год назад

    Great guidance, But I am watched the video 10 times 🥲🥲
    But i am still getting this error
    An error occurred (AccessControlListNotSupported) when calling the PutObject operation: The bucket does not allow ACLs.
    This is the policy included in my Bucket
    {
    "Version": "2012-10-17",
    "Id": "Policy1700*******99",
    "Statement": [
    {
    "Sid": "Stmt170*******49",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::ump-ai-tutor-v1/*"
    }
    ]
    }

    • @learnwithkilter3432
      @learnwithkilter3432 Год назад

      Oww Now its fixed
      i changed AWS_DEFAULT_ACL = "public-read" to AWS_DEFAULT_ACL = None

    • @CloudWithDjango
      @CloudWithDjango  Год назад +2

      Hi,
      Thank you for your feedback! :)
      This error is occurring because you have different needs and expectations with your application regarding the use of a PutObject.
      You can try to check the following and add the PutObject API action in your JSON policies as such:
      {
      "Version": "2012-10-17",
      "Id": "Policy1700*******99",
      "Statement": [
      {
      "Sid": "Stmt170*******49",
      "Effect": "Allow",
      "Principal": "*",
      "Action": [
      "s3:GetObject",
      "s3:PutObject" // Add this line to allow the PutObject action
      ],
      "Resource": "arn:aws:s3:::ump-ai-tutor-v1/*"
      }
      ]
      }