modern-django-starter/apps/accounts/management/commands/setup_social_apps.py
Django Template 85f68a8df9 Complete authentication system with modern UI
- Add modern authentication templates with black/white theme
- Implement email/password and Google OAuth login/signup
- Configure SMTP email delivery for verification emails
- Create clean, rectangular authentication cards
- Remove Facebook integration, keep Google only
- Add responsive auth design with reduced font sizes
- Fix Django settings for production-ready email backend
- Update Google OAuth credentials and callback URLs
- Generate secure SECRET_KEY for production

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 12:26:22 +05:30

36 lines
1.2 KiB
Python

from django.core.management.base import BaseCommand
from allauth.socialaccount.models import SocialApp
from django.contrib.sites.models import Site
from decouple import config
class Command(BaseCommand):
help = 'Set up social authentication applications'
def handle(self, *args, **options):
site = Site.objects.get_current()
# Create Google OAuth2 app if it doesn't exist
google_app, created = SocialApp.objects.get_or_create(
provider='google',
name='Google',
defaults={
'client_id': config('GOOGLE_OAUTH2_CLIENT_ID', default='your-google-client-id'),
'secret': config('GOOGLE_OAUTH2_CLIENT_SECRET', default='your-google-client-secret'),
}
)
google_app.sites.add(site)
if created:
self.stdout.write(
self.style.SUCCESS('Created Google OAuth2 application')
)
else:
self.stdout.write(
self.style.WARNING('Google OAuth2 application already exists')
)
self.stdout.write(
self.style.SUCCESS('Social applications setup completed!')
)