Articles on: Websites & APIs

How to host Django applications

1. Prerequisites

  • Square Cloud Account: Create your account via the Registration Page (Email or GitHub).
  • Active Plan: A paid plan is required for hosting. Check the pricing here.



2. Production Settings (settings.py)


Before deploying, you need to adjust your Django project's settings.py file to allow Square Cloud traffic:


  • ALLOWED_HOSTS: Add the subdomain you intend to use and the Square Cloud domain.
ALLOWED_HOSTS = ['yoursubdomain.squareweb.app', 'yourdomain.com', 'localhost', '127.0.0.1']
  • DEBUG: For production, remember to set DEBUG = False.
  • Static Files: Make sure to configure STATIC_ROOT so Django knows where to collect static files.



3. Performing the Deployment


  1. Cleanup: Remove unnecessary folders such as venv/, .git/, and __pycache__ cache files.
  2. Compression: Create a .zip file containing the root of the project (where the manage.py file is located). The requirements.txt file must be in the project root and contain at least:
Django
gunicorn
  1. Upload: In the Square Cloud Dashboard, click on upload new application.
  2. Web Publishing: In the submission menu, check the "Publish to Web" option.
  3. Subdomain: Define the desired subdomain (e.g., myproject.squareweb.app).
  4. Custom Start Command: For your Django application to run in production, you must configure the start command to use Gunicorn on port 80. At the time of upload or in the squarecloud.app file, use:
python -m gunicorn --bind 0.0.0.0:80 your_project.wsgi:application
  • --bind 0.0.0.0:80: Binds the application to the interface and port required by Square Cloud.
  • your_project.wsgi:application: Replace your_project with the name of the folder containing the wsgi.py file.



4. Custom Domains (Standard+ Plan)


If you have a Standard plan or higher, you can use your own domain:

  • Configure the domain (e.g., www.yoursite.com) in the Network tab.
  • SSL (HTTPS) is automatically configured and renewed by Square Cloud at no additional cost.



5. Optimization and Security Tips


  • Static Files: In Django, remember to run the "python manage.py collectstatic" command or configure Gunicorn/Middleware (such as WhiteNoise) to serve static files in production.
  • Environment Variables: Use the Dashboard's ENV tab to hide your SECRET_KEY and database credentials. Never leave passwords exposed in the code sent to the repository or dashboard.
  • Database: For production, use PostgreSQL or MySQL instances available on Square Cloud, avoiding the use of SQLite in applications that require scalability.

Updated on: 05/26/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!