Browse files

Added helpful error message to SiteManager.get_current() if the user …

…hasn't set SITE_ID

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
adrianholovaty committed Jul 12, 2007
1 parent 8c4cc32 commit 06fc225ae6e00ed47f02eef7f6699e61cc76430e
Showing with 6 additions and 1 deletion.
  1. +6 −1 django/contrib/sites/
@@ -4,7 +4,12 @@
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)

0 comments on commit 06fc225

Please sign in to comment.