12

I have the django-registration setup and it sends emails - yay!

However, it's decided that it would be ace to call my site "example.com", which is not the name I decided to use. Cool name, but not for me.

How do I change example.com to something else? I read somewhere that I go to the admin page but - spoiler alert - I've never used the admin page in django and am not actively planning on this currently (but maybe someday?)

So I go to the admin page - /admin/sites/site/ - and sure enough I can see "example.com" and "domain name". But now what? I added my sites domain name and "display name", but how do I select to use it? I even deleted example.com!

However, the email insists on still sending out example.com. All the sites I read just say "use admin", but I don't know if maybe my admin is broken (which would be odd, as I really haven't touched it) or if there is a link i'm missing?

Any ideas?

Will
  • 11,276
  • 9
  • 68
  • 76
bharal
  • 15,461
  • 36
  • 117
  • 195

2 Answers2

10

The entry you saw originally on the admin/sites/site/ page, with example.com and domain name, is the one you should simply edit for the quickest results (instead of adding a new Site object).

What's really happening?

In your settings file, Django automatically defines a SITE_ID property when you create your project, which is by default set to 1. This points to the example.com Site you see in the admin. If you want to use the Site object you created, or change Site objects later when you need the functionality, you can change that SITE_ID property to the id of the Site object you created. Hope this helps!

Herman Schaaf
  • 46,821
  • 21
  • 100
  • 139
  • ahhhhh. let me give that a whirl. i should have noted that after deleting example.com registration fails because the id "1" isn't in the db anymore. Silly me, and it all makes sense now with what you said~! – bharal Jul 07 '12 at 12:15
  • just to be clear - i fixed my problem by adding a new entry into the django_site table. The entry had an id of one, and then my domain and display name - phew! It now all works, brilliant and thanks. – bharal Jul 07 '12 at 12:21
3

The site object in the template comes from the Django Site model. When you do a syncdb, it defaults automatically to example.com

If you login to Django's admin interface, you will find "Sites". Inside it, you will be able to change example.com to whatever you like. Just set the id of the site u want to use as current site in your settings.py as SITE_ID = ID. e.g if you editted the example.com domain name to mysite.com and display name as MYSITE. then SITE_ID = 1 because that is the only content we have in our "Sites" table and its ID is 1. if like to add another "Sites" details leaving the example.com untouched, remember to set the SITE_ID to ID of the one u added

enter image description here

Transformer
  • 3,642
  • 1
  • 22
  • 33