Articles on: Websites & APIs
This article is also available in:

How to host Django on Square Cloud (step by step)

Looking for where to host a Django app or the best way to put a Django app online? This guide shows the step-by-step to host Django on Square Cloud — from settings⁠.py (ALLOWED_HOSTS) to deploying with Gunicorn, running 24/7.


1. Prerequisites

  • Square Cloud Account: Create your account via the Registration Page (email, Discord, GitHub or Google).
  • 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']
CSRF_TRUSTED_ORIGINS = ['https://yoursubdomain.squareweb.app', 'https://yourdomain.com']
  • CSRF_TRUSTED_ORIGINS: Behind Square Cloud's HTTPS, forms (including the admin) return 403 CSRF without it.
  • 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
whitenoise
  1. Upload: In the Square Cloud Dashboard, click on upload new application.
  2. Web Publication: In the upload form, open the advanced settings and fill in "Web Publication" (Subdomain). It must be set on the first upload.
  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: Gunicorn doesn't serve static files. Install WhiteNoise (its middleware right after SecurityMiddleware) and run collectstatic, for example in the start command: python manage⁠.py collectstatic --noinput && python -m gunicorn your_project.wsgi --bind 0.0.0.0:80.
  • 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: 10/04/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!