[Django]-Django forms not rendering on production server – work fine locally with testserver, and unit tests pass on production server

2👍

In case another poor soul ends up here. Check that your packages (pip freeze) are the same locally and on the server. I had django-filter==0.15.0 locally and django-filter==0.10.0 on the server which was causing this exact issue with no errors being raised.

1👍

So, I have resolved the problem. Unfortunately I’m not entirely sure how.

As I mentioned in my update, turning off gunicorn and using the django test server instead fixed the issue. I shut down the testserver and fired up gunicorn again, and… the forms were still rendering correctly.

My suspicion is that restarting gunicorn was all that was needed. I don’t know why, or if that was definitely what fixed it. Oh well.

0👍

I had the same issue when I deployed my django project to AWS EC2.

If you’ve followed Nginx gunicorn and Django tutorials your best option is to reboot the EC2 and then restart the gunicorn server. This has solved my issue.

👤IVI

0👍

You should restart your web sever every time you deploy – that will make sure you are running the latest code for your app. It’s very deceptive because it will correctly pull the html templates, but not run the code that renders the content for the templates (that’s why you’re seeing your labels which are hard-coded but not the text inputs which are rendered dynamically).

I use Apache on Ubuntu and this gets me every once in a while when I’ve been up all night debugging something…Always restart your server when you deploy fresh code:

sudo service apache2 restart

👤Ben

Leave a comment