VOOZH about

URL: https://www.geeksforgeeks.org/python/create-newsletter-app-using-mailchimp-and-django/

⇱ Create Newsletter app using Mailchimp and Django - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Create Newsletter app using Mailchimp and Django

Last Updated : 23 Jul, 2025

In this article, we'll use MailChimp and Django to make a simple mailing app. When people subscribe to our app, we'll learn how to create an audience list and save the users in MailChimp using Python.

Have you considered how they could send emails to subscribers with only one click? MailChimp is the greatest email marketing software. It also allows you to manage your audiences and send bulk emails by allowing you to build multiple lists. However, simply sending emails is insufficient. It should have some appealing MailChimp layouts and text, and you may choose preset templates for your email directly.

Create MailChimp Free Account:

To create a MailChimp account and get an API key follow the below steps:

Step 1: Go to MailChimp.com and signup for free. Also, set up the profile of your account.

Step 2:  Now, to get the API key, From the bottom left of your screen, Go to the profile>> Extras >> API Key >> Create API Key. Furthermore, it would help if you store your API key. We will use it later in our Django app.

👁 Image
 

Step 3: Next, we need to create an audience list. Go to https://login.mailchimp.com/?referrer=%2Flists%2F, and click on the Create Audience. Fill in the required details and see your audience on the audience dashboard.

👁 Image
 

Step 4: Now, we need to get the audience list id. Go to the audience settings -> list id. Store the list id to use it in the Django app.

👁 Image
 

Create Django APP:

Step 1: Users need to enter the below command into the terminal to create a new Django App.

django-admin startproject mailchimpNewsletter

Step 2: Next, go to the project directory.

cd mailchimpNewsletter

Now, users need to create a views.py file in the project directory. Also, create a templates folder and create a home.html  ( templates>> home.html ) ,success.html, and error.html file in that.

Project structure: It should look like this.

👁 Image
 

Step 3: Before we dive into setting up the project, install the Mailchimp-marketing python library by entering the below command to the project directory.

pip install mailchimp-marketing

Step 4: In this step, we will integrate Mailchimp with the Django App.

  • urls.py: Add the below code with the code of the urls.py file. We have set up the URLs for our Django App in this file.
  • views.py: In this file, we will add basic code to subscribe the user to Mailchimp.
  • home.html: It is the basic template to collect the user's email, first name, and last name.
  • success.html: We will redirect a user to this template when they subscribe to our newsletter successfully.
  • error.html: We will redirect a user to this template when some error occurs while subscribing to our newsletter.

Step 5: Add 'DIRS' : [os.path.join.(BASE_DIR, 'templates')] in your templates list.

👁 Image
 

Step 6: To run the project on your terminal, go to the project directory and enter the below command.

python manage.py runserver

Output: You will see that the app is running successfully on localhost:8000.

👁 Image
 

At last, in MailChimp, you can go to the Audience >> All contacts, and you will see the list of all added contacts.

👁 Image
Comment
Article Tags: