• This repository has been archived on 01/Feb/2019
  • Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created about 13 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

DEPRECATED, this project is no longer maintained, see README for more information.

Deprecated

This project is no longer supported.

Divio will undertake no further development or maintenance of this project. If you are interested in taking responsibility for this project as its maintainer, please contact us via www.divio.com.

Django Mailchimp v1.3

This is an integrated app for Django dealing with the Mailchimp mailing list system.

Warning

This package used to be called simply django-mailchimp. But since the mailchimp API changed in non-backwards-compatible ways between v1.2 and v1.3, we renamed it to django-mailchimp-v1.3.

Stuff may break in funny ways with this release, so make sure to thoroughly test your code if you want to update from django-mailchimp.

Quick start guide:

Installation:

  1. Install django-mailchimp-v1.3:

    pip install django-mailchimp-v1.3
    
  2. Add a MAILCHIMP_API_KEY to your settings.py with your mailchimp API key as the value (obviously)

  3. Add mailchimp to your project's list of INSTALLED_APPS

4. To start using the API, you should start by using utils.get_connection(). This will use the API_KEY you just defined in settings.py

Subscribing a user to a list:

  1. To get the list:

    list = mailchimp.utils.get_connection().get_list_by_id(<list key id>)
    
  2. Now add a member to the mailing list:

    list.subscribe('[email protected]', {'EMAIL':'[email protected]'})
    

Those pesky merge vars:

General info:

Mailchimp is a quite generic service. As such, it needs to store information on people who subscribe to a list, and that information is specific to this very list!

So to help you build dynamic forms (presumabely), mailchimp added the merge_vars. They are, basically, a dictionnary showing infromation and meta-information defined for each piece of information. Here's what the default set of merge vars look like (ona brand new list with default options):

[
    {
    'field_type': 'email',
    'name': 'Email Address',
    'show': True,
    'default': None,
    'req': True,
    'public': True,
    'tag': 'EMAIL',
    'helptext': None,
    'order': '1',
    'size': '25'
    },{
    'field_type': 'text',
    'name': 'First Name',
    'show': True,
    'default': '',
    'req': False,
    'public': True,
    'tag': 'FNAME',
    'helptext': '',
    'order': '2',
    'size': '25'
    },{
    'field_type': 'text',
    'name': 'Last Name',
    'show': True,
    'default': '',
    'req': False,
    'public': True,
    'tag': 'LNAME',
    'helptext': '',
    'order': '3',
    'size': '25'
    }
]

As you can see, it's a list of 3 dictionnaries, each containing several fields that you should use to build your user interface with (since you're using this app, that means your Django form).

Obtaining them:

You can recreate this list using the following API call:

list = mailchimp.utils.get_connection().get_list_by_id(<The list's key ID>)
print list.merges

Using them:

When you make a post to mailchimp, you need to pass merge_vars. For example, in a new list created with the default settings on the mailchimp website, the following call adds a member to a list (with a little more info than our bare minimum example up there):

list = mailchimp.utils.get_connection().get_list_by_id(<The list's key ID>)
list.subscribe('[email protected]', {'EMAIL': '[email protected]', 'FNAME': 'Monthy', 'LNAME': 'Pythons'})

Note the use of the 'tag' field as the key for fields (why they didn't call it 'key' or 'id' is beyond comprehension).

Create a view:

We'll now try to move up the stack and create the necessary elements to make a useable mailchimp interface

Fire up your favorite editor and open your views.py. Put in the following snippet of code:

from django.http import HttpResponseRedirect
from mailchimp import utils

MAILCHIMP_LIST_ID = 'spamspamspamspameggsspamspam' # DRY :)
REDIRECT_URL_NAME = '/mailing_list_success/'
def add_email_to_mailing_list(request):
    if request.POST['email']:
        email_address = request.POST['email']
        list = utils.get_connection().get_list_by_id(MAILCHIMP_LIST_ID)
        list.subscribe(email_address, {'EMAIL': email_address})
        return HttpResponseRedirect('/mailing_list_success/')
    else:
        return HttpResponseRedirect('/mailing_list_failure/')

Of course, if you feel redirecting the user is not the right approach (handling a form might be a good idea), feel free to adapt this simple example to your needs :p

More Repositories

1

django-simple-sso

Python
298
star
2

django-cms-tutorial

django CMS Tutorial
109
star
3

documentation-framework

"The Grand Unified Theory of Documentation" (David Laing) - a popular and transformative documentation authoring framework
91
star
4

aldryn-newsblog

A combined news/weblog application for Aldryn and django CMS – part of the Essential Addons.
Python
67
star
5

djangocms-rest-api

A REST API for django CMS
Python
51
star
6

aldryn-search

Haystack 2.0 search index for django CMS
Python
48
star
7

aldryn-bootstrap3

DEPRECATED, this project is no longer maintained, see README for more information.
Python
44
star
8

aldryn-forms

Flexible HTML forms for your django CMS projects
Python
40
star
9

django-cms-explorer

django CMS explorer theme example
CSS
30
star
10

django-simplegallery

DEPRECATED: django gallery app
Python
30
star
11

django-polls

Django tutorial's polls app
Python
27
star
12

django-login-as

Log in as any user in django (if you're a superuser)
Python
26
star
13

django-cms-demo

django CMS demo for development, research and fun
Python
26
star
14

divio-cli

Command line interface to the Divio Cloud (formerly aldryn-client)
Python
21
star
15

django-emailit

deadsimple html emails
Python
20
star
16

django-appmedia

symlinks or builds appmedia for django projects
Python
18
star
17

python-mautic

Python
17
star
18

django-contentblock

A simple app that allows using Multilingual contentblock using Placeholders from django-cms
Python
15
star
19

djangocms-table

Django CMS plugin for creating tables
JavaScript
13
star
20

djangocms-grid

A multi-column plugin, that uses a common grid system.
Python
12
star
21

django-cms-jplayer

MP3 Player plugin for the django-cms
JavaScript
12
star
22

aldryn-django

An opinionated Django setup for Divio Cloud
Python
12
star
23

aldryn-categories

Python
12
star
24

divio-cloud-docs

Divio Cloud documentation for developers
Python
12
star
25

djangocms-boilerplate-bootstrap4

django CMS Bootstrap 4 Boilerplate for Divio Cloud
JavaScript
11
star
26

django-cms-divio-quickstart

A Dockerised django CMS project, ready to deploy on Divio or another Docker-based cloud platform, and run locally in Docker on your own machine. A Divio account is not required.
Python
10
star
27

djangocms-oembed

A set of oembed plugins (currently only video) for django CMS.
Python
9
star
28

django-cronjobs

Define your cronjobs and intervals in Python code. A single cronjob (management command) then runs all these jobs.
Python
9
star
29

django-dploi

A deployment helper using fabric and buildout
Python
9
star
30

djangocms-boilerplate-webpack

Advanced django CMS boilerplate with Bootstrap3, Webpack, Babel etc.
CSS
9
star
31

aldryn-people

People and Organizations
Python
9
star
32

django-divioadmin

divio modifications to django.contrib.admin
Python
9
star
33

django-cms-preview

Dockerfile for a django CMS preview
Python
7
star
34

browserslist-saucelabs

Browserslist to Sauce Labs capabilities converter
JavaScript
7
star
35

aldryn-sites

Extensions to django.contrib.sites
Python
6
star
36

aldryn-boilerplates

An extension that allows re-usable apps to provide sets of templates and staticfiles for different boilerplates.
Python
6
star
37

djangocms-accordion

Accordion Plugin for django CMS
Python
6
star
38

cmsplugin-banner

Python
5
star
39

aldryn-sso

Single sign-on Integration for Divio Cloud
Python
5
star
40

djangocms-teaser

Python
5
star
41

djangocms-stacks

Python
5
star
42

aldryn-apphooks-config

Python
5
star
43

django-gsa

A thin wrapper for using a Google Search Appliance (GSA) for searches in django.
Python
5
star
44

aldryn-translation-tools

Collection of translation helpers and mixins
Python
5
star
45

django-divio-quickstart

A Dockerised Django project, ready to deploy on Divio or another Docker-based cloud platform, and run locally in Docker on your own machine. A Divio account is not required.
Python
5
star
46

ac-base

Base images for Python projects deployed on Divio Cloud.
Dockerfile
5
star
47

aldryn-django-cms

An opinionated django CMS setup bundled as an Divio Cloud addon
Python
5
star
48

django-storage-url

Python
4
star
49

djangocms-link-manager

DEPRECATED, this project is no longer maintained, see README for more information.
Python
4
star
50

aldryn-common

A library of helpful utilities for packages in the django CMS/Aldryn ecosystem
Python
4
star
51

no-devops-please

But I never wanted to do DevOps! A Cloud deployment workshop for Python programmers
Python
4
star
52

cmsplugin-iframe

A simple iframe plugin for django-cms
Python
4
star
53

ac-wheelsproxy

PyPI compatible proxy to build and serve wheels for specific platforms.
Python
4
star
54

django-standardsettings

A package that helps standardise our common settings for all projects
Python
4
star
55

djangocms-project

a example project using django-cms. does not work, as we have not opensourced all dependencies YET.
Python
4
star
56

nginx-boilerplate

Divio Cloud based boilerplate to develop with NGINX
HTML
4
star
57

djangocms-boilerplate-bootstrap3

django CMS Bootstrap 3 Boilerplate for Divio Cloud
JavaScript
4
star
58

djangocms-translations

Send django CMS content for translation to 3rd party providers.
Python
3
star
59

divio-wagtail-puput

A Divio Cloud addon to install the Wagtail Puput weblog
Python
3
star
60

saleor-boilerplate

Divio Cloud based boilerplate to develop with Saleor
Python
3
star
61

multi-python

A docker multi-architecture Docker image with tox and multiple Python version installed, ideal for CI.
Dockerfile
3
star
62

django-redirects-hvad

A modified version of django.contrib.redirects with multilingual target URLs
Python
3
star
63

djangocms-inherit

DEPRECATED, this project is no longer maintained, see README for more information.
Python
3
star
64

aldryn-apphook-reload

Reload urls of django CMS Apphooks without a restart
Python
3
star
65

django-tinymce

Mirror and contributions to django-tinymce. original is here: http://code.google.com/p/django-tinymce/
JavaScript
3
star
66

django-commontranslations

prevents repeating translations across apps and projects
Python
3
star
67

aldryn-celery

An opinionated Celery setup bundled as an Aldryn Addon. To be used together with aldryn-django. * Deprecated *
Python
2
star
68

djangocms-flash

Python
2
star
69

djangocms-internalsearch

Python
2
star
70

django-celery-divio-quickstart

Python
2
star
71

djangocms-boilerplate-foundation6

django CMS Foundation 6 Boilerplate for Divio Cloud
CSS
2
star
72

djangocms-tutorial-addon

Tutorial addon for step 9 of https://www.django-cms.org/en/blog/2016/02/16/build-a-website-without-knowing-python-django-part-one/
Python
2
star
73

djangocms-versioning-filer

Python
2
star
74

aldryn-addons

This is the basis for the Divio Cloud Addon's Framework
Python
2
star
75

djangocms-timed

Python
2
star
76

aldryn-redirects

A modified version of django's django.contrib.redirects app that supports language dependant target URLs, using django-hvad
Python
2
star
77

django-apptemplate

a standard django app
2
star
78

docs-theme

Sass
1
star
79

django-commonsearch

Common search utilities
Python
1
star
80

djangocms-personalisation

Successor of aldryn-segmentation.
Python
1
star
81

php-laravel-boilerplate

PHP
1
star
82

aldryn-django-oscar

Aldryn Django Oscar
Python
1
star
83

divio-telemetry-apm

Python
1
star
84

express-boilerplate

Divio Cloud based boilerplate to develop with Express
JavaScript
1
star
85

php-laravel6-boilerplate

PHP
1
star
86

application-documentation

Guidelines and example for creating application documentation
1
star
87

application-documentation-starter-files

Starter files for building application documentation
Python
1
star
88

djangocms-salesforce-forms

An IDEXX specific aldryn-forms extension that submits to SalesForce Marketing Cloud (SFMC)
Python
1
star
89

djangocms-boilerplate-html5

django CMS HTML5 Boilerplate for Divio Cloud
CSS
1
star
90

the-opinions-company

A simple project to demonstrate migration to Divio Cloud
JavaScript
1
star
91

divio.github.com

JavaScript
1
star
92

djangocms-casper-helpers

Helpers for testing django CMS applications / plugins in Casper.js
JavaScript
1
star
93

getting-started-with-express

JavaScript
1
star
94

node-boilerplate

Divio Cloud based boilerplate to develop with Node
JavaScript
1
star
95

django-multisite-plus

Python
1
star
96

getting-started-with-aspnet-core

HTML
1
star