How to Deploy a Django Project to China?
Tags: django, python, webdev, devops
Published: 2021-02-25 23:45:43

---
canonical_url: https://www.21cloudbox.com/solutions/how-to-deploy-django-project-in-production-server.html
---
# What is Django?

Django is an open source web application framework developed based on Python. The Django framework not only provides a complete code directory structure, but also uses the structure model, view, and template.  This makes the code easy to standardize during the development process. Among them, Django Admin provides an out-of-the-box back-end management system and is the "Go-To" by many Python developers and startups.

21YunBox provides a very simple Django deployment method in China. You can deploy on the 21YunBox in the **Python** environment.


# How to Deploy Django in China?

1. Register as a [21YunBox member](https://www.21yunbox.com/u/signup/)  
2. Create a [PostgreSQL database](https://launch-in-china.21yunbox.com/solutions/how-to-create-a-postgresql-database.html)
3. Fork [django example](https://gitee.com/eryiyunbox-examples/django-hello-world)  
4. Create a **Cloud Service** on the 21YunBox, and allow the 21YunBox to access your code base
5. Configure the following settings

**Environment**
```bash
PYTHON 3.7
```

**Build command**:
```bash
./build.sh
```

**Start command**:
```bash
gunicorn hello.wsgi:application
```

Click **Advanced Configuration** to configure environment variables:

| KEY                      | VALUE                                       |
| :--------------------:   | :-----------------------------------------: |
| **DJANGO_DB_URL**        | In the first step to create a cloud database <br> midpoint **Database URL** Obtain|
| **DJANGO_ALLOWED_HOSTS** | **`<service name>.21yunbox.com,127.0.0.1`** |

> For more Django-related configurations, please refer to [Official Document](https://docs.djangoproject.com/en/2.2/topics/settings/).
> In this example, `DJANGO_DEBUG=True` is a demonstration and example only. You can set `DJANGO_DEBUG` to `False` in the environment variable when it goes live.


Once the build is complete, use the **remote connection** of the 21YunBox to create a Django administrator account
```bash
./manage.py createsuperuser
```

It's that easy! When the build is completed, your application will be accessible in the subdomain of 21YunBox.

If the description of the above text is not clear, you can refer to the following actual operation video:
[How to Deploy Django Application to Server](https://www.bilibili.com/video/BV1Br4y1c7C4)

<br>
# Why Choose 21YunBox?

> 21YunBox is a Cloud Service Platform based out of Beijing, China. We specialize in modern web hosting and automation solutions. This enables you to set up websites instantly.  

> **Have questions about hosting and deploying in China? Let us know, we are happy to help!** <21YunBox@gmail.com> 

To learn about the differences between 21YunBox and these foreign (outside of China) cloud service platforms, please refer to:

* [21YunBox vs Heroku](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-heroku-in-china.html)
* [21YunBox vs Netlify](https://launch-in-china.21yunbox.com/blog/solutions/alternatives-to-netlify-in-china.html)
* [21YunBox vs Vercel](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-vercel-in-china.html)
* [21YunBox vs Gatsby Cloud](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-gatsby-cloud-in-china.html)
* [21YunBox vs Github Pages](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-github-pages-in-china.html)
* [21YunBox vs Surge.sh](https://launch-in-china.21yunbox.com/solutions/how-to-speed-up-surgesh-in-china.html)
* [Compare in terms of function and price: 21YunBox vs Heroku, Netlify, Vercel](https://www.21yunbox.com/compare-others/)

<br>
*This article's content originated [here](https://launch-in-china.21yunbox.com/solutions/how-to-deploy-django-project-in-production-server.html)*

*For additional detail and future modifications, refer the original post.*