Email confirmation with Mailgun

Automatically verifying our superuser

Want more?

This lesson for enrolled students only. Join the course to unlock it!

You can see the code changes implemented in this lecture below.

If you have purchased the course in a different platform, you still have access to the code changes per lecture here on Teclado. The lecture video and lecture notes remain locked.
Join course for $15

New files

# Generated by Django 5.0.3 on 2024-11-22 14:16

from django.db import migrations
from allauth.account.models import EmailAddress
from allauth.account.utils import user_email

class Migration(migrations.Migration):
    dependencies = [
        ("app", "0006_alter_userprofile_managers_alter_userprofile_email"),
    ]

    def verify_superuser(apps, schema_editor):
        from django.contrib.auth import get_user_model

        User = get_user_model()
        superuser = User.objects.get(email="example@example.com")

        email, created = EmailAddress.objects.get_or_create(
            user=superuser, email=user_email(superuser)
        )
        email.verified = True
        email.save()

    operations = [migrations.RunPython(verify_superuser)]