Commit 747fa609 authored by Michal Čihař's avatar Michal Čihař

Do not fail syncdb and creating user if backend database is not ready

parent 9dc327a3
...@@ -4,6 +4,7 @@ from django.contrib.auth.models import User ...@@ -4,6 +4,7 @@ from django.contrib.auth.models import User
from django.conf import settings from django.conf import settings
from django.contrib.auth.signals import user_logged_in from django.contrib.auth.signals import user_logged_in
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.db.utils import DatabaseError
from django.utils.translation import ugettext_lazy as _, gettext, ugettext_noop from django.utils.translation import ugettext_lazy as _, gettext, ugettext_noop
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.models import Group, Permission, User from django.contrib.auth.models import Group, Permission, User
...@@ -209,9 +210,13 @@ def create_profile_callback(sender, **kwargs): ...@@ -209,9 +210,13 @@ def create_profile_callback(sender, **kwargs):
''' '''
if kwargs['created']: if kwargs['created']:
# Create profile # Create profile
try:
profile, newprofile = Profile.objects.get_or_create(user = kwargs['instance']) profile, newprofile = Profile.objects.get_or_create(user = kwargs['instance'])
if newprofile: if newprofile:
profile.save profile.save
except DatabaseError:
# Database not set up (we're being run from initial syncdb)
pass
# Add user to Users group if it exists # Add user to Users group if it exists
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment