Comment

Comment by leetrout

This isn't wrong advice but their tone of authority seems a bit misplaced.

1. Make settings.py a package

2. Please do not put anything more than imports in __init__.py since you are adding logic downstream.

3. Use django environ https://github.com/joke2k/django-environ which gives you a defined schema of your environment needs with casting and default values when needed.

Now you keep your .env files, keep your setting overrides (settings/base.py, settings/local.py, etc) when needed AND you have defined a schema with non-string types for your environment variables.

From the readme you can see how you make a schema with a casted type and default value:

  env = environ.Env(
      DEBUG=(bool, False)
  )
parent leetrout 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton