0

I want to know the proper way of creating subdomain in django. Take for instance, a django project that has more than one apps and you want to assign subdomain to each. Apart from using django-hosts; what can one do in production especially if one deploys to digitalocean with gunicorn and nginx?

Note: I've tried django-hosts which worked well locally but did flopped in production as my static files couldn't be located.

I've search online and I don't seem to see a solution to this.

Thanks in advance

1 Answer 1

0

Making a subdomain in django at production is relatively simple and straight forward.

N.B: you don't need any plug in like django-hosts or django-subdomain to make this happen.

What I did with my project is splitting it into two different projects calling them different names.

I put both of the projects in the same projectdir as recommended when deploying single project to digitalocean using nginx and gunicorn.

I created gunicorn.sock and gunicorn.service for each project changing gunicorn to the name of the project e.g if my projects name is blog and forum, I will have blog.sock and blog.service for blog and created corresponding name for the other project.

The same thing will be done for nginx too. You place the domain that you want in the server part of the nginx.

Make sure that you properly fill the directory well especially the gunicorn.service(in this case, blog.service and the other).

Also, if you want to run any command relating to gunicorn, you will the name of your service file.

Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.