diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-07-12 05:23:47 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-07-12 05:23:47 +0000 |
| commit | 06fc225ae6e00ed47f02eef7f6699e61cc76430e (patch) | |
| tree | 1b1d4fd3a127ac8b316b2052b87032d7312fd337 | |
| parent | 8c4cc3235239d4d9d39a6294443a9cce0a7a7a81 (diff) | |
Added helpful error message to SiteManager.get_current() if the user hasn't set SITE_ID
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5652 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/sites/models.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py index 276c58474c..1b71601899 100644 --- a/django/contrib/sites/models.py +++ b/django/contrib/sites/models.py @@ -4,7 +4,12 @@ from django.utils.translation import ugettext_lazy as _ class SiteManager(models.Manager): def get_current(self): from django.conf import settings - return self.get(pk=settings.SITE_ID) + try: + sid = settings.SITE_ID + except AttributeError: + from django.core.exceptions import ImproperlyConfigured + raise ImproperlyConfigured("You're using the Django \"sites framework\" without having set the SITE_ID setting. Create a site in your database and set the SITE_ID setting to fix this error.") + return self.get(pk=sid) class Site(models.Model): domain = models.CharField(_('domain name'), maxlength=100) |
