Skip to content

Instantly share code, notes, and snippets.

@getup8
Created June 10, 2016 00:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save getup8/7862fd86f8e48781587490f25417d7b9 to your computer and use it in GitHub Desktop.
Save getup8/7862fd86f8e48781587490f25417d7b9 to your computer and use it in GitHub Desktop.
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from allauth.socialaccount.models import SocialApp
class Command(BaseCommand):
help = 'Loads allauth SocialApp settings into database'
def handle(self, *args, **options):
for provider, config in settings.SOCIALACCOUNT_APPS.items():
try:
social_app = SocialApp(provider=provider,
name=config['name'],
client_id=config['client_id'],
secret=config['secret'])
social_app.save()
social_app.sites = [settings.SITE_ID]
social_app.save()
self.stdout.write(self.style.SUCCESS(
'Successfully created app: {}'.format(social_app)))
except:
raise CommandError('Error creating social app.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment