Permalink
Browse files

allow for empty Sites table post-migrate

  • Loading branch information...
1 parent 8a602b8 commit c468b5f01ae996193981db0eb7227b8ee0062ba1 @davewhiteland davewhiteland committed Sep 1, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 pylib/djangoproj/binalerts/management/__init__.py
@@ -31,9 +31,13 @@ def update_default_site(app, **kwargs):
domain = settings.DOMAIN_NAME
name = settings.BINS_SITENAME
- s = Site.objects.all()[0]
- s.domain = domain
- s.name = name
+ s = Site.objects.all()
+ if s:
+ s = s[0]
+ s.domain = domain
+ s.name = name
+ else:
+ s = Site(domain=domain, name=name)
s.save()
Site.objects.clear_cache()

0 comments on commit c468b5f

Please sign in to comment.