I added my custom domain (Web service → Settings → Add custom domain). Followed the instructions given in render’s documentation to set up my dns on Google domains. Set up a CNAME, A, and CAA. Got my domain verified in my Render web service, but when I try to go to my domain (jeanpy.dev) I get a Bad Request (400).
I can see in my web service’s logs the requests when I try going to my domain jeanpy.dev (deleted some bits from the log):
I suggest keeping your config in the environment rather than the code. I think Django looks for ALLOWED_HOSTS by default, so it shouldn’t need any code changes.
I also wouldn’t set any vars in the shell as they would be lost on next deploy, I’d set it on the Render service in the “Environment” tab.
I don’t think you’d need ALLOWED_HOSTS locally, as it’ll likely be in Debug mode and you also won’t be using the onrender.com (or custom domains) in that environment. If you’re looking to keep a parity of project environment variables maybe consider a .env file & “dotenv” library.