A holographic guide to launching your project into the digital cosmos.
1. Prepare Project
Configure settings & dependencies.
2. Version Control
Push code to a Git repository.
3. Hosting & DB
Set up hosting & production database.
4. Environment
Securely manage secret keys.
5. Deploy & DNS
Go live and connect your domain.
6. Final Checks
Collect static files and test.
Need Help with Deployment?
At MetaStack, we specialize in robust, scalable Django deployments.
Let our experts handle the complexities of launching and maintaining
your application, so you can focus on building great features.
Version control is essential for tracking changes and collaborating.
Pushing to a remote repository (like GitHub) is the standard way to
deploy code.
A. Initialize Repository
If you haven't already, initialize a Git repository in your project's
root directory.
git init
B. Commit Your Code
Stage and commit all your project files. This creates a snapshot of
your code.
git add .
git commit -m "Initial commit for deployment"
C. Push to Remote
Link your local repository to a remote one on GitHub, GitLab, or
Bitbucket and push your changes. Your hosting provider will pull the
code from here.
# Example for GitHub
git remote add origin https://github.com/your-user/your-repo.git
git push -u origin main
Step 3: Hosting & Database
Choose a platform to host your application and a robust database for
your production data.
A. Choose a Hosting Provider
Platforms-as-a-Service (PaaS) like Railway, Heroku, or Render simplify
deployment by managing the underlying infrastructure. Link your Git
repository to the provider.
B. Provision a Production Database
The local SQLite database is not suitable for production. Provision a
managed PostgreSQL or MySQL database through your hosting provider.
They will give you a connection URL (a `DATABASE_URL`).
Use environment variables to store sensitive data and configuration that
differs between environments.
A. What to Store
Never commit these to version control. Set them in your hosting
provider's dashboard.
`SECRET_KEY`: Your Django secret key.
`DATABASE_URL`: The connection string from your production database.
`DEBUG`: Set to `False` in production.
`ALLOWED_HOSTS`: Your production domain(s).
B. Setting Variables on Host
All hosting providers have a section in their project settings, often
called "Variables" or "Config Vars," where you can securely add these
key-value pairs.
Step 5: Deploy & Configure DNS
It's time to go live! Trigger the deployment and point your custom
domain to the application.
A. Deploy the Application
Pushing to your main branch usually triggers an automatic deployment
on your hosting provider. The host will read your `Procfile` (or
similar) to know how to start the web server.
# Example Procfile
release: python manage.py migrate
web: gunicorn myproject.wsgi
B. Configure DNS
Your hosting provider will give you a target URL (e.g.,
`app-name.onrender.com`). Go to your domain registrar (like Cloudflare
or GoDaddy) and create a `CNAME` record to point your domain (e.g.,
`www.yourdomain.com`) to that target URL.
Step 6: Final Checks & Launch
Perform final tasks on the live server to ensure everything runs
smoothly.
A. Collect Static Files
If your CSS or JS isn't loading, you may need to run `collectstatic`.
Many hosts do this automatically, but if not, you can run it via their
CLI or shell.
python manage.py collectstatic --no-input
B. Create a Superuser
You'll need an admin user on the live database to access the Django
admin panel. Use the host's shell/console to run this command.
python manage.py createsuperuser
C. Test Everything
Visit your live URL. Click through pages, test forms, and check the
admin panel to ensure everything is working as expected.
Congratulations, you've deployed your app!