Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Christopher Stuart
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 Points

Django and Sendgrid Best Practices

I'm trying to think through a few things and wondering if anyone has experience in integrating Sendgrid with Django.

I was able to successfully change my settings.py file to implement Sengrid as my mailer and I am able to send transactional emails via my website/sendgrid.

Now, i would like to create a mailing list to keep subscribers to my site up to date.

On my site, i allow a user to signup with email and some other info--that gets saved in my postgres database.

I am also creating a subscription form on my site to save users to sendgrid mailing list.

I'm getting confused as to how to integrate the two.

For example if new users are signing up through my site....i want to make sure they are included on my sendgrid mailing list--for when i send out a promotional email.

I would think that maybe I need to simultaneously save the user's email to sendgrid somehow upon user creation? But I have no experience doing so. Would this be the best way to handle this problem?

Thanks!

1 Answer

Ryan S
Ryan S
27,276 Points

Hi Christopher,

Yes you are on the right track about saving the user's email to sendgrid upon signup. That would work well.

You can utilize Sendgrid's API for adding users to a mailing list. See the docs for Contacts API. In the List and Recipients sections, there are a number of endpoints available for adding recipients, managing lists, etc.

So when a user signs up, you could first make a call to add them: Add a Single Recipient - POST

Then with their new sendgrid contact id and the List id, you can add them to that list: Add a Single Recipient to a List - POST

If you don't know the list id you can also get that through the API.

There is also a Python Library which is really helpful for interacting with Sendgrid's API.

Hope this helps.

Christopher Stuart
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 Points

Thanks Ryan your comments are much appreciated.

I'm also wondering about Mailchimp...seems as if Sendgrid's email templating isn't quite on part with that of Mailchimp.

I wonder if you have experience in that as well...like would I be best to leave Sendgrid for transactional emails and leave Mailchimp to handle the newsletter list and the associated mailing for it.

IF you have any thoughts would love to hear. Thanks!

Ryan S
Ryan S
27,276 Points

No problem.

I don't have much experience with Mailchimp, so unfortunately I can't comment on their email templates. I have used Sendgrid for transactional emails quite a bit though, and I do find that they work really well from a functional standpoint. I will admit that I found their template creation a little frustrating to work with at times, so I wouldn't be surprised if there are other options out there that are easier to work with. But in general I have no complaints with sendgrid.

It looks like Mailchimp has really good documentation so if you find their marketing emails easier to work with then I'm sure you can accomplish everything you need to with Mailchimp.