Web Hosting With Django and PostgreSQL
Web Hosting with Django and Postgre
Once your application has reached a stage where it needs to go public or at least no longer run from your development computer, the next step should be setting up some kind of production infrastructure. In this article we’ll show how to deploy it on Heroku with their hosted PostgreSQL database serving as its backend.
Any Django app needs a database to organize data. By default, Django apps store their information in an SQLite file; however, many developers prefer PostgreSQL’s reliability and scalability.
Django can create an automatic persistent connection to the database upon each request if DATABASE_URL is set; otherwise it will use SQLite instead. When reaching its maximum lifetime defined by CONN_MAX_AGE or no longer usable, its connection will close itself automatically.
Django automatically generates an extra index for model field when its db_index=True property is set for it, making use of PostgreSQL lookup types like LIKE and contains.
Digital Ocean and Railway both provide fast deploys with hosted databases, while Appliku provides services specifically targeted towards Django and other Python frameworks with pre-made templates to deploy apps quickly. If desired, Django hosting may also be hosted directly on servers running Ubuntu or Debian operating systems.