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_ROOTso Django knows where to collect static files.
3. Performing the Deployment
- Cleanup: Remove unnecessary folders such as
venv/,.git/, and__pycache__cache files. - Compression: Create a
.zipfile containing the root of the project (where themanage.pyfile is located). Therequirements.txtfile must be in the project root and contain at least:
Django
gunicorn
- Upload: In the Square Cloud Dashboard, click on upload new application.
- Web Publishing: In the submission menu, check the "Publish to Web" option.
- Subdomain: Define the desired subdomain (e.g.,
myproject.squareweb.app). - 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.appfile, 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: Replaceyour_projectwith the name of the folder containing thewsgi.pyfile.
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_KEYand 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
Thank you!
