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

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

Related

Google Cloud AppEngine and Django: how should I set the domain name for have it work?

I've deployed a Django project on Google Cloud standard AppEngine,
My Domain Name is registered in Google Domains which confirms that it already points to my project when I try to customize my domains.
On the Web, I've access my project under its project name:
https://mooveup-9645.oa.r.appspot.com
However when I try https://my-domain.fr the web site cannot be accessed.
My Question is:
Where should I add my domain name ?
if APPENGINE_URL:
# Ensure a scheme is present in the URL before it's processed.
if not urlparse(APPENGINE_URL).scheme:
APPENGINE_URL = f"https://{APPENGINE_URL}"
ALLOWED_HOSTS = [urlparse(APPENGINE_URL).netloc, "www.my-domain.fr", "my-domain.fr"]
Is this the appropriate solution in Django settings or is there another configuration step with GCP?
You must add the Custom Domain in the GCP console:
https://console.cloud.google.com/appengine/settings/domains?project={your_project}
On Google Cloud tutorial to deploy an Django project on AppEngine, some steps are skipped.
On Django Settings complete the ALLOWED_HOSTS with your domain name.
If you have a Standard AppEngine in order to avoid the overload of the Engine, the better is to deploy and then delete the former versions, in order to alleviate the risk of Error 502:
$ gcloud app deploy --project PROJECT_ID --promote
$ gcloud app versions list --project PROJECT_ID //to get the older versions
$ gcloud app versions delete VERSION_ID
Then:
On https://console.cloud.google.com/appengine/settings, you should customize your domain name and end your domain name with a DOT in order to get the DNS records and then update them on https://domains.google.com/registrar/

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/

Changed domain for Django app, can't reach url

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?

Django powered site and micro sites – do I have to create a separate project for each microsite?

I'm looking to build a Django website with the main site on example.com. On this domain, a user can register using an email and password and start writing blog posts at example.com/blog. Admins will be able to login into the Django Admin to alter posts and change content on the other pages of example.com.
The website will have one microsite each year on subdomains, e.g., 2013.example.com, 2014.example.com, etc. Admins will be able to edit content using the Django Admin.
I'm going to deploy the Django project onto Heroku.
The question that I would answered is whether I should create a new Django app and Heroku deployment for each microsite and the main site? Or, whether I can create it all as one Django project?
The latter seems to make more sense to me, but unsure how I would go about it.