views:

1357

answers:

5

Is there any newsletter app for django, allowing users to subscribe-unsubscribe for newsletters? I'd like to have an app that's easy to use and administered via the Django admin.

+2  A: 

Maybe, maybe not. It wouldn't be too hard to have an app that has a many-to-many association between a Newsletter (however that is imagine) and a Subscriber (foreign key on User or firstName/lastName/emailAddress/password).

Your models would be something like this:

from django.db import models
from django.contrib.auth.models import User

class Subscriber(models.Model):
    user = models.ForeignKey(User)
    email = models.EmailField()

    def __unicode__(self):
        return "User %s" % (self.user.username, )

    @models.permalink
    def get_absolute_url(self):
        return ('subscriber', None, {'object_id' : self.id})

    class Meta:
        ordering = [ "id" ]

class Newsletter(models.Model):
    name = models.CharField(max_length=80)
    subscribers = models.ManyToManyField('Subscriber')
    # .... Other stuff

    def __unicode__(self):
        return "Newsletter %s" % (self.name, )

    @models.permalink
    def get_absolute_url(self):
        return ('newsletter', None, {'object_id' : self.id})

    class Meta:
        ordering = [ "id" ]

Your urls.py would be something like this:

from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template

urlpatterns = patterns('',
    url(r'^subscriber/(?P<object_id>\d+)/$', views.subscriberview, name='subscriber_view'),
    url(r'^newsletter/(?P<object_id>\d+)/$'', views.newsletterview,name='newsletter_view'),
    url(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT}),
)

Is that enough to get you going?

hughdbrown
sweet...this looks good enough to start me off. Thanks
A: 

Try djangolist

DjangoList is a django app that will allow doing mass mailings and manage newsletter from which users can subscribe/unsubscribe. DjangoList is currently under development and is not ready to use.

Alexandr
+5  A: 

you should have a look at this project http://github.com/Fantomas42/emencia-django-newsletter

Fernandez Roger
Thanks, it seems really interesting.
Pierre-Jean Coudert
A: 

I've decided to create my own solution for assembling the text and handling subscriptions, but I think I'm going to use django-mailer to keep track of what was sent and how did it end up.

che
+1  A: 

Hey Stephen,

You might want to have a look at my app, simply called django-newsletter. It allows for the administration of multiple newsletters, user subscriptions (they don't have to give their email address or confirm anything and uses templates from the database for messages (with support for both text and HTML). The app is currently in production use and a 0.1 release is scheduled within about a week.

For submission of large quantities I would suggest something like Postmark, which can be used with Django as well. (This could be easily used with the newsletter app, as soon as I have moved from using Django's old (SMTP) mail API to the new backend-agnostic one.

But surely, if simple subscription management is all you need you can just use 'github.com slash howiworkdaily slash' django-newsletter which does just that. (And yes, we were first to use that name. :P Sorry about the URL - but apparently stackoverflow uses some kind of ridiculous spam prevention mechanism.)

Mathijs