Creation of subdomain in django project

O
ojophilip
Ojo Philip Odeniyi
  • 8 Jun

Sorry, this is unrelated to spirit django.

I need a help in creating subdomain for one of the apps in my project. I've tried implementing django-hosts which worked well locally but on production couldn't detect static files for the subdomain.

I deployed the project to digitalocean, everything is working fine but for the subdomain.

Can anyone pls enlighten me on how to create subdomain in django project deployed to digitalocean?

nitely
Esteban C Borsani
  • 9 Jun

One way is having two django servers, one for the main domain, and one for the subdomain. You can share the same code for both applications, just have some setting to register one set of URLs or the other. Also, you may need to have different setting files for both applications, not sure.

About django'hosts and the static files issue, better ask in their github issues, or on StackOverflow

O
ojophilip
Ojo Philip Odeniyi
  • 12 Jun

@nitely, thanks for your reply.

By two servers, do you mean to ngnix files? I was wondering how have two settings file or do you making that django a project?

Thanks

M
  • 14 Jun

@ojophilip, create two users on your server or two folder, like site/project1 and site/project2. Install in each folder virtual environment. Then tine nginx for main domain and sub

O
ojophilip
Ojo Philip Odeniyi
  • 14 Jun

@Marci, thanks very much

O
ojophilip
Ojo Philip Odeniyi
  • 14 Jun

I've been able to do this by splitting the project into two and deploy into different folder but with the same user.

It's working perfectly now

M
  • 19 Jun

ojophilip, wow! That's just what I need for my website! could you say in more detail how you managed to run together your main website and this forum. Especially interesting, did you setup a common authentication system for them. I mean, if a user logs in to the website, he is already logged in the forum.

O
ojophilip
Ojo Philip Odeniyi
  • 19 Jun

@miha_romanov, this new project is does not have this forum integrated in it. However, for my former project I did use common authentication for the main site and the forum.

For the authentication, I made use of django-allauth while retaining the forum profile as it is important for the forum also. It should be noted however that I didn't deploy spirit-forum as a project on its own but as apps