You only need to set the PGDATA variable in the script that starts the server. The client only cares about the port.
You do have to set the port value if you must run it on a non-standard port. I assume you have a good reason to not just run it on the default port? If you do run it on the default port (5432), it will just work without any parameters for it at all.
If you are running it on a different port, you should make two changes:
- In postgresql.conf, set the port= value to the new port you want, and restart the database server.
- In your settings.py in django, set the DATABASE_PORT value to the new port you want.
You should definitely not need to use environment variables for simple configuration options like these - avoiding them will make your life easier.