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 6162693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:41:49+00:00 2026-05-23T21:41:49+00:00

Using django-contact-form , I have overridden the form class: from contact_form.forms import ContactForm from

  • 0

Using django-contact-form, I have overridden the form class:

from contact_form.forms import ContactForm
from django.conf import settings

class ContactFormPublic(ContactForm):

    tuples = settings.WORKSHOP_ADMINS
    recipient_list = [mail_tuple[1] for mail_tuple in tuples]
    from_email = 'Joe Jones <joe@jones.org>'

That works, but I want the from_email to be that of the name and email submitted in the form itself. Tried referring to “self.email” in the form, but it complains that self is not defined. Seems like it should be simple, but I’m not able to tell from the documentation how to solve this.

Thanks.

  • 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-23T21:41:51+00:00Added an answer on May 23, 2026 at 9:41 pm

    Ok, I took a look at the ContactForm class. The easiest way I can see to set the from_email to the email submitted in the form is to override ContactForm.get_messge_dict:

    from contact_form.forms import ContactForm
    from django.conf import settings
    
    class ContactFormPublic(ContactForm):
    
        tuples = settings.WORKSHOP_ADMINS
        recipient_list = [mail_tuple[1] for mail_tuple in tuples]
    
        def get_message_dict(self):
            if not self.is_valid():
                raise ValueError("Message cannot be sent from invalid contact form")
            message_dict = {}
    
            """
            I removed 'from_email' from the message_part tuple check and updated the
            message_dict, setting the 'from_email' to the value of self.email
            """
            for message_part in ('message', 'recipient_list', 'subject'):
                attr = getattr(self, message_part)
                message_dict[message_part] = callable(attr) and attr() or attr
            message_dict.update({'from_email' : getattr(self, 'email')})
    
            return message_dict
    

    Hope that helps you out.

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

Sidebar

Related Questions

Using django-tinymce I have successfully embedded TinyMCE in the Admin before. Embedding it in
I have been using Django for web-development, and have become quite fond of that
I am using Django to receive and process push notifications from the foursquare real-time
Learning django from learning website development using django. In chapter 3, building a bookmark
We are now using Django to develop a multilingual website. We have different language
I have a simple website in django where the content is static. Where i
Using Django 1.1: The Django admin docs describe using arbitrary methods or attributes on
Using django templates I would like to split a block of text on the
When using django, I believe you can swap out the built-in orm for sqlalchemy
I am using django generic views, how do I get access to the request

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.