dj-database-url
dj-database-url
is another app that helps with the configuration of your Django application. Specifically, it allows you to set the database (that your Django app connects to) using a URL instead of a dictionary of configuration values. As you can see in your existing settings.py
file, the DATABASES
setting contains a couple of items and gets more verbose when using a different database that has more configuration options (for username, password, and so on). We can instead set these from a URL, which can contain all these values.
The URL’s format will differ slightly, depending on whether you are using a local SQLite database or a remote database server. To use SQLlite on disk (as Bookr is currently), the URL is like this:
sqlite:///<path>
Note there are three slashes present. This is because SQLite doesn’t have a hostname, so this is like a URL being like this:
<protocol>://<hostname>/<path>
That is, the URL has...