Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I set my site url in django settings?

Ok I think I must be missing something. In settings.py I don't see the setting for absolute url for the site. I see there is MEDIA_URL.

django-registration references {{ site }} which is defaulting to example.com but I'm not seeing that in any settings.

If I want the dev.mysite.com and mysite.com to work independently, what do I need to put in settings.py?

like image 755
Derek Organ Avatar asked Aug 21 '10 03:08

Derek Organ


People also ask

How do I change the default URL in Django?

Set up app folder's urls.py and html files In the same directory, you should have a file named views.py. We will create a function called index which is what makes the http request for our website to be loaded. Now, we've set it up such that http://127.0.0.1:8000/homepage will render the HTML template index.

How do I get my URL back in Django?

You can do that by using request. META['HTTP_REFERER'] , but it will exist if only your tab previous page was from your website, else there will be no HTTP_REFERER in META dict . So be careful and make sure that you are using . get() notation instead.


2 Answers

The site uses the sites framework. The example.com domain is defined in the database and can be changed with the Django admin.

To use 2 sites simultaneously you will have to change the SITE_ID in the settings and add the extra site in the Django Admin.

like image 157
Wolph Avatar answered Sep 18 '22 02:09

Wolph


If you only want to use it from your own code -- just put the domain in a variable in settings-production.py and settings-dev.py (or whatever you choose to call them).

django itself won't do pay any attention to the domain you specify -- but it doesn't need to.

like image 33
Dan O'Huiginn Avatar answered Sep 18 '22 02:09

Dan O'Huiginn