Django Static Files Not Loading After EC2 Deployment with Nginx

72 views
Skip to first unread message

Kiran Barai

unread,
Aug 29, 2024, 4:06:41 PM8/29/24
to Django users

Hello everyone,

  1.  I’m having trouble with my Django project after deploying it on an EC2 instance. The issue is that my static files (CSS, JavaScript) are not loading correctly.
  2. second issues in URL: - 
    issue with a Django project where the URL generated using the {% url %} template tag is not rendering correctly. Instead of getting the proper URL, the rendered URL appears to be incorrectly encoded and includes the literal template tag.           When clicking a button or link that is supposed to navigate to a specific view, the URL appears as follows: 
    https://mydomain/%7B%%20url%20'save-file-history'%20%%7D


Thank you


Ryan Nowakowski

unread,
Aug 29, 2024, 8:04:35 PM8/29/24
to django...@googlegroups.com


On August 28, 2024 10:40:46 AM CDT, Kiran Barai <kiranbara...@gmail.com> wrote:

> 1. I’m having trouble with my Django project after deploying it on an
> EC2 instance. The issue is that my static files (CSS, JavaScript) are not
> loading correctly.

What error are you getting?

> 2. second issues in URL: -
> issue with a Django project where the URL generated using the {% url %}
> template tag is not rendering correctly. Instead of getting the proper URL,
> the rendered URL appears to be incorrectly encoded and includes the literal
> template tag. When clicking a button or link that is supposed to
> navigate to a specific view, the URL appears as follows:
> https://mydomain/%7B%%20url%20'save-file-history'%20%%7D

Post the snippet of your template with the tag

Abdul Qoyyuum Haji Abdul Kadir (Agent Q)

unread,
Aug 29, 2024, 10:23:23 PM8/29/24
to Django users

Jayesh Bafna

unread,
Sep 1, 2024, 4:23:22 PM9/1/24
to django...@googlegroups.com

Look into whitenoise if you want to serve it from ec2 / Django-storages if from s3+ CloudFront directly.

If you're using docker you might need to mount the staticfiles path on the container.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/782477cd-de0a-49c4-b249-a4872a76caban%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages