Changed domain for Django app, can't reach url - django

I recently moved my website from django to an e-commerce platform. I would still like to use Django and Python for various web-tools so after pointing the website domain at the new host I added a subdomain of tools.domain.com. I then changed the "domain" collumn in the django_site table to the new subdomain "tools.domain.com" and restarted the app. I can get to my admin area and login but when I attempt to access the url of the tool as defined in urls.py i get a "Page unavailable" error. I haven't edited settings.py or url.py.
What am I missing in this process?

Related

Django, website with changed prefix, how to fix urls globally

I recently deployed my app locally with the help of Apache. I use server name and sufix to get to the content as http://my-server/app. The Problem is every button ignores what the root of my app is. So from my main view at my-server/app I try to redirect to /second_page and it sends me to server/second_page instead of server/app/second_page. Do I have to change every form by hand or is there any way to configure it through settings.py or urls.py?

Serve multiple Django applications from one server

Good morning. I have a dedicated ubuntu server behind my company's firewall. It is using Django, Gunicorn, and Nginx to serve an Intranet application to employees. The original app responds to the URL [server_name]/[original_application_name]. I want to serve additional apps from this server. I have followed this tutorial as I did when setting up the original app.
I can run Gunicorn and serve the app, I have created a second systemd service file that appears steady (copied from the original app with paths changed - service runs), same for a new 'sites-available' file in Nginx (copied from original and modified), new .sock file exists, binding appears successful. However, I have yet to hit on the right configuration combination between settings.py [allowed_hosts], [new_app].service, and nginx etc.
The original app is running and when I try a URL related to the new app it gives an error saying it cannot find the request in the url.py of the original app. The new app would be used by the IT dept. Ideally, the new URL would be something like: it.[server_name]/[new_application_name].
I have looked through other cases with this problem but most use Apache or are on a public hosting site. I have seen this but it requires a "socket file". My original app is not using a socket file. I was hoping to do this without interfering with the original app. Is a "socket file" required? How can I configure this to serve both apps? Never having done this, what will the new URL be? The URL for the admin site in both apps is 'admin/', how can I accommodate this? Thanks!
I combined into one file as you suggested and I am almost there! I have original site responding at [server_name]/inventory and new site responding at [server_name]/assets. Great! My only problem is the admin page. In both apps the admin site is called admin! So, [server_name]/admin brings up the original site. How can I get to the new admin page?

How do I change my weblate site url

I installed my own weblate server somewhere, then I switched my nginx configuration to a domain name. I went into weblate's django admin, in sites section and updated the site entry to point to the right location.
I couldn't find anything related to this within settings.py. There's a default site id, but it's already set to 1.
After doing this, urls to projects were still using old url.
Update site entry in django admin and Restart the weblate django application. After restarting weblate, the new url from database started working.
There is also this documented section:
https://docs.weblate.org/en/latest/admin/management.html#changesite
Which should refresh website.

Multiple Domains django app on heroku

Django have nice sites framework, so i thought can it posissible to store on heroku app with multi-settings structure and join it with differents domains on one heroku instance?
According to the docs, you can use Django sites framework with Heroku if you set SITE_ID = None. In that case Django will automatically detect current site based on request.get_host() method. So you only have to add specific hosts in admin panel.
The SITE_ID setting specifies the database ID of the Site object associated with that particular settings file. If the setting is omitted, the get_current_site() function will try to get the current site by comparing the domain with the host name from the request.get_host() method.
https://docs.djangoproject.com/en/1.8/ref/contrib/sites/

How do you add a Purchased Domain Name using Django need Steps

I recently purchased a Domain Name from GoDaddy and I used Django Frameworks and have already built the site with HTML5 and CSS4 and bootstrap my problem is were do I add my custome Domain Name in Django I have looked everywhere on the web but no one seems to know
Thanks
It seems you are looking for ALLOWED_HOSTS settings. It can be found in your project's settings.py file. Usage:
ALLOWED_HOSTS = ['.example.com']
More info here: https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
I. For your development environment:
Django includes a framework called "Sites" which enables setting the domain name and website name for your Django project through the admin interface. To enable sites, go to the settings.py script of your project and:
add 'django.contrib.sites' to the INSTALLED_APPS
at the bottom of your settings add SITE_ID = 1
migrate your database (open the terminal, go to the project directory, and run $ python manage.py migrate) to create the corresponding records on your database (there is no need to run $ python manage.py makemigrations)
Now you can browse to http://localhost:8000/admin/sites and edit the domain name and website name from your browser. Notice that the admin site should be previously enabled.
Once you save the changes, other django modules will make use of the new domain name and project name (for example: all email you send through an email backend will produce links using your new domain settings).
For more information, check: https://docs.djangoproject.com/en/4.0/ref/contrib/sites/
II. On the production environment:
You will need to choose your django server platform (for example: Amazon AWS EC2, IBM Cloud, Heroku, GoDaddy, etc)
You may find some guides on how to deploy your django app on these links:
AWS: https://dev.to/rmiyazaki6499/deploying-a-production-ready-django-app-on-aws-1pk3
IBM cloud: https://developer.ibm.com/tutorials/deploy-django-applications-to-ibm-cloud/
Heroku: https://www.dothedev.com/blog/deploy-django-app-free-heroku-complete-guide/
GoDaddy: https://www.dothedev.com/blog/2019/12/03/host-your-django-app-on-godaddy/
III. On your domain provider:
Most of the websites offering domain name for sale will provide you with an interface to manage the DNS (Domain Name Service) records for your domain. These records associate the IP address of your website (you should get it from your web server) to your www.domain.com
Likewise, DNS records will associate the mail servers of your choice to your domain.
For an example on how to manage your DNS records go to: https://www.godaddy.com/help/manage-dns-records-680