mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Error checking in profile migration.
This commit is contained in:
parent
bd784e85e4
commit
362459a3f9
1 changed files with 6 additions and 2 deletions
|
@ -6,6 +6,7 @@ from south.v2 import DataMigration
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from apps.social.models import MSocialProfile
|
||||
from mongoengine.queryset import OperationError
|
||||
|
||||
class Migration(DataMigration):
|
||||
|
||||
|
@ -14,8 +15,11 @@ class Migration(DataMigration):
|
|||
user = User.objects.create(username='popular', email='popular@newsblur.com')
|
||||
user.set_password("%s-%s" % (random.random(), random.random()))
|
||||
user.save()
|
||||
profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
|
||||
profile.save()
|
||||
try:
|
||||
profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
|
||||
profile.save()
|
||||
except OperationError:
|
||||
print " ---> Whoops, already have a popular user."
|
||||
|
||||
def backwards(self, orm):
|
||||
"Write your backwards methods here."
|
||||
|
|
Loading…
Add table
Reference in a new issue