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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:09:37+00:00 2026-05-17T20:09:37+00:00

another Django send_mail question. Seems like I have problems displaying data in an email

  • 0

another Django send_mail question. Seems like I have problems displaying data in an email that separate form from function. Seems like this is a variable problem.

Edit: I manage to make the client name show up! Now how can to the same thing with invoice. Say that I wanted to display the date, invoice_no, work_orders & contract_info?

    #models.py
    class Invoice(models.Model):
    client = models.ForeignKey(Client)
    date = models.DateField()
    invoice_no = models.CharField(max_length=16)
    work_orders = models.ManyToManyField(Work_Order)
    contract_info = models.ForeignKey(Contract_Info)

    def __unicode__(self):
                return self.invoice_no

    #views.py
    @login_required
    def invoice_mail(request, id=1):
        invoices_list = Invoice.objects.filter(pk=id)
        client = invoices_list[0].client
        t = loader.get_template('registration/email.txt')
        c = Context({
        'client': client.company,
        })
        send_mail('Welcome to My Project', t.render(c), 'jess@example.com', ['mark@example.com'], fail_silently=False)
        return render_to_response('email.html', locals(), context_instance=RequestContext(request))

Here is my email.txt

Dear {{client}},

And when I send it to my email account I receive this

Dear Currys,

  • 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-17T20:09:37+00:00Added an answer on May 17, 2026 at 8:09 pm

    This is nothing to do with send_mail. You are sending this to your template context”

    c = Context({
        'invoice': 'invoice.client',
        })
    

    Here ‘invoice’ is a string containing the text ‘invoice.client’. You need to send an actual object. However your naming is unclear, so I can’t tell whether you want to send the Invoice object, or the related Client.

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

Sidebar

Related Questions

another django question. I have a edit form like this. Look at current_status in
I'm trying to have Django (on top of GAE) fetch data from another web
I wrote a certain function that I'd like all my Django models to have.
My app in Django scraps and imports data from another application's HTML. I tested
I have two models, one a vanilla Django model, another an unmanaged model wrapping
another newbie-question regarding rails and bootstrap. I am using something like this: <div class=tabbable
In my Django app, I have a Newsletter model. Now I'd like to be
I have a list of python dictionaries that look like this: sandwiches = [
I have to change the is_staff option from views.py file to disabling the Django-admin
I have a text area in a django based website that displays the content

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.