Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5992109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:29:03+00:00 2026-05-22T23:29:03+00:00

I have a function from django-registration which re-sends an activation email to the given

  • 0

I have a function from django-registration which re-sends an activation email to the given recipients. I am trying to convert the function from accepting multiple users for a given email to only one user per email. However, it is throwing an AttributeError when I try and change it.

def resend_activation(self, email, site):   # for multiple emails -- this works
    sent = False
    users = User.objects.all().filter(email=email)

    if users:
        for user in users:
            registration_profiles = self.all().filter(user=user)
            for registration_profile in registration_profiles:
                if not registration_profile.activation_key_expired():
                    registration_profile.send_activation_email(site)
                    sent = True
    return sent

def resend_activation(self, email, site):   # for single email -- this does not work
    sent = False                            
    user = User.objects.all().filter(email=email)

    if user:
        registration_profile = self.all().get(user=user)
        if not registration_profile.activation_key_expired():
            registration_profile.send_activation_email(site)
            sent = True
    return sent

This latter function throws an AttributeError, but I can’t figure out why the function won’t ‘work’ without a for loop. What seems to be my problem here? Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:29:04+00:00Added an answer on May 22, 2026 at 11:29 pm

    try:

    def resend_activation(self, email, site):
        sent = False
        # Get the user you are looking for
        try:
            single_user = User.objects.get(email=email)
        except User.DoesNotExist:
            return false
    
        # Get all the profiles for that single user
        registration_profiles = self.all().filter(user=user)
            # Loop through, and send an email to each of the profiles belonging to that user
            for registration_profile in registration_profiles:
                if not registration_profile.activation_key_expired():
                    registration_profile.send_activation_email(site)
                    sent = True
        return sent
    

    In the original, User.object.filter(email=email) is returning a queryset which is a collection of objects from the database that were returned from the query filter(email=email). The for loop in the original is looping through each of these objects, and sending a corresponding email. You were trying to call the send_

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function which gets a key from the user and generates a
i have a function which retrieves values from a webservice , then loops through
I have the following Django Model which retrieves 3 records from a database. The
I have a Django app, which populates content from a text file, and populates
I have created a django application. In my application i have a registration from
Assuming that I have function get_a_color in a Django views.py: from django.utils import simplejson
I have this function from a plugin (from a previous post) // This method
I have to create the sin function from scratch in my Comp Sci class,
I have a form I am submitting using jQuery's ajaxSubmit function from the Forms
I have an array of values that is passed to my function from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.