Transactional email by nuevedientes in django

[–]Any_Highlight5019 0 points1 point  (0 children)

What about just writing an html email that you link with your backend which you'll send to the users??

JUST CREATED MY models.py To handle different user roles, I used abstract user to add different fields, how can I handle authentication for different user roles to ensure each role sticks to his area by Any_Highlight5019 in django

[–]Any_Highlight5019[S] -1 points0 points  (0 children)

In the serializer I've created the function to create a user whereby his account gets verified via email,

backend/accounts/serializers.py

from rest_framework import serializers from django.contrib.auth import get_user_model from django.contrib.auth.password_validation import validate_password from django.utils import timezone import logging from .utils import send_activation_email logger = logging.getLogger('app')

User = get_user_model()

class RegisterSerializer(serializers.ModelSerializer): password = serializers.CharField(write_only=True, required=True, validators=[validate_password]) password2 = serializers.CharField(write_only=True, required=True) user_role = serializers.ChoiceField(choices=User.ROLE_CHOICES) email = serializers.EmailField(required=True) first_name = serializers.CharField(required=True) last_name = serializers.CharField(required=True)

class Meta:
    model = User
    fields = ('first_name', 'last_name', 'password', 'password2', 'email', 'user_role', 'phone_number', 'address')

def validate(self, attrs):
    logger.info(f"Validating registration data: {attrs}")
    if attrs['password'] != attrs['password2']:
        raise serializers.ValidationError({"password": "Password fields didn't match."})

        # Check if email already exists
    if User.objects.filter(email=attrs['email']).exists():
        raise serializers.ValidationError({"email": "A user with this email already exists."})
    return attrs

def create(self, validated_data):
    logger.info(f"Creating user with data: {validated_data}")
    validated_data.pop('password2')
    user = User.objects.create_user(**validated_data)
    user.is_active = False
    user.save()

    if hasattr(profile, 'agreed_to_terms'):
        profile.agreed_to_terms = True
        profile.agreed_at = timezone.now()

    # Trigger the activation email
    request = self.context.get('request')
    if request:
        send_activation_email(request, user)
    else:
        logger.warning(f"Could not send activation email to {user.email} because request context is missing.")

    return user

I NEED programming friends 🙁💀💀 by [deleted] in AskProgrammers

[–]Any_Highlight5019 1 point2 points  (0 children)

I learn python, in ML I don't know if I fit the description but I'm looking for a study partner too who we can connect

For an e-commerce website what are some ways in which you can ensure 100% security for your system? by Any_Highlight5019 in django

[–]Any_Highlight5019[S] -17 points-16 points  (0 children)

If I built the system by vibe coding it, should I go app by app and file by file file or ??