Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 06fc225ae6e00ed47f02eef7f6699e61cc76430e 1 parent 8c4cc32
Adrian Holovaty authored July 12, 2007

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  django/contrib/sites/models.py
7  django/contrib/sites/models.py
@@ -4,7 +4,12 @@
4 4
 class SiteManager(models.Manager):
5 5
     def get_current(self):
6 6
         from django.conf import settings
7  
-        return self.get(pk=settings.SITE_ID)
  7
+        try:
  8
+            sid = settings.SITE_ID
  9
+        except AttributeError:
  10
+            from django.core.exceptions import ImproperlyConfigured
  11
+            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.")
  12
+        return self.get(pk=sid)
8 13
 
9 14
 class Site(models.Model):
10 15
     domain = models.CharField(_('domain name'), maxlength=100)

0 notes on commit 06fc225

Please sign in to comment.
Something went wrong with that request. Please try again.