DEV Community

Cover image for Create a News-Curator and News Subscription App using Django
Maksudul Haque
Maksudul Haque

Posted on

Create a News-Curator and News Subscription App using Django

I have recently released a django package named django-newsfeed.
This makes it really easy to build a news curator and newsletter subscription website.

Today I'm going to show you how to easily create a news curator website or
add a newsfeed subscription service to your existing website.


  • Django >= 2.2
  • django-newsfeed
  • celery
  • celery-beat
  • redis

Setup Project:

Lets get started

  1. Create Virtualenv and install requirements:
$ mkvirtualenv example-newsfeed     # you can use virtualenv instead of virtualenvwrapper
$ mkdir django-newsfeed
$ cd django-newsfeed/

$ pip install celery Django django-celery-beat django-newsfeed redis

** You need to have redis installed in your system. Here is a guide

  1. Setup django:
$ startproject example_newsfeed .    # dot (.) is added to create project on current directory
$ python migrate
  1. Now add newsfeed and celery-beat to installed apps.
  1. Add django-newsfeed urls to project
urlpatterns = [
    path('newsfeed/', include('newsfeed.urls', namespace='newsfeed')),
  1. Create superuser and Run Django Development Server
$ python createsuperuser
$ python runserver       #
  1. Go to Django Admin Page, login and create Posts, Issues and Newsletters.

Now You can navigate to:

  • latest_issue: newsfeed/
  • issue_list: newsfeed/issues/
  • issue_detail: newsfeed/issues/<slug:issue_number>/
  • newsletter_subscribe: newsfeed/subscribe/
  • newsletter_subscription_confirm: newsfeed/subscribe/confirm/<uuid:token>/
  • newsletter_unsubscribe: newsfeed/unsubscribe/
  1. Override Templates to your liking. To learn more about it click here Here is the code for this tutorial. You can see the overridden templates here. It uses bootstrap to style the templates.

Setup Sending Newsletters:

Now that the project is set up we can create celery task to send newsletters.

Configure Celery

  1. Setup celery from here.

  2. Add celery settings for redis to

# Celery Settings
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
  1. Add Email settings to
# Email Settings
EMAIL_HOST = 'test_host'
EMAIL_HOST_USER = 'test_user'
EMAIL_HOST_PASSWORD = 'test_password'
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

** Change this for production server django reference

  1. Create a django app named core
$ python startapp core
  1. Now add core to installed apps.
  1. Create file in the core app directory. Paste this code in the file.
from celery.decorators import task

from newsfeed.models import Newsletter
from newsfeed.utils.send_newsletters import send_email_newsletter

def send_email_newsletter_task(newsletters_ids=None, respect_schedule=True):
    newsletters = None

    if newsletters_ids:
        newsletters = Newsletter.objects.filter(

** This will enable you to call the EmailNewsletterSender provided by django-newsletter
in a celery task.

Now you can send newsletters from the django admin page.

  1. Add this code to the file on your project directory. ( file should be created following the step 3)
app.conf.beat_schedule = {
    'send_email_newsletter': {
        'task': 'send_email_newsletter_task',
        # run this task every hour
        'schedule': crontab(minute=0, hour='*'),

** This will schedule sending newsletters every hour.
Now you can send scheduled newsletters to all the subscribers autometically using this scheduled task.

  1. Add this code to the file on the core app directory.
from django.contrib import admin, messages

from newsfeed.admin import NewsletterAdmin
from newsfeed.models import Newsletter

from .tasks import send_email_newsletter_task

class NewsletterAdmin(NewsletterAdmin):

    def send_newsletters(self, request, queryset):
        newsletter_ids = list(queryset.values_list('id', flat=True))

            'Sending selected newsletters(s) to the subscribers',

** This will override the admin action for sending newsletters to use celery task.

Source Code for this tutorial here:

Video Demo:

A Example News Curator and News Subscription website using django package dnajgo-newsfeed


You can learn more about all the configuration for django-newsfeed on github.

Checkout the package from here: django-newsfeed


If you use this package please feel free to provide some feedback on twitter
or on the comment section.
If you have any suggestion or want to contribute to this package
please create an issue
and read the contribution guide.

Feedback and Contribution is always welcome.

Top comments (0)