A news curator and newsletter subscription package for Django
GPL-3.0 License
.. image:: https://badge.fury.io/py/django-newsfeed.svg :target: https://badge.fury.io/py/django-newsfeed
.. image:: https://github.com/saadmk11/django-newsfeed/actions/workflows/test.yaml/badge.svg :target: https://github.com/saadmk11/django-newsfeed/actions/workflows/test.yaml
.. image:: https://codecov.io/gh/saadmk11/django-newsfeed/branch/master/graph/badge.svg :target: https://codecov.io/gh/saadmk11/django-newsfeed
.. image:: https://github.com/saadmk11/django-newsfeed/workflows/Changelog%20CI/badge.svg :target: https://github.com/saadmk11/changelog-ci
django-newsfeed
is a news curator and newsletter subscription package for django.
It can be used to create a news curator website which sends newsletters to their subscribers
also it can be used to add a news subscription section to your website.
draft
issue support.ajax
support) with e-mail verification.ajax
support).You can view the example project for this package here
_.
This is a news-curator and newsletter subscription application that only uses this package.
It also uses celery
, celery-beat
and redis
to send email newsletters in the background.
The styles in the example project uses bootstrap
.
.. _here: https://github.com/saadmk11/test-django-newsfeed
Install django-newsfeed
using pip:
.. code-block:: sh
pip install django-newsfeed
Then add newsfeed
to your INSTALLED_APPS
:
.. code-block:: python
INSTALLED_APPS = [
...
'newsfeed',
]
Then add newsfeed
to your projects urls.py
:
.. code-block:: python
urlpatterns = [
...
path('newsfeed/', include('newsfeed.urls', namespace='newsfeed')),
...
]
Available views
We provide these views out of the box:
newsfeed/
newsfeed/issues/
newsfeed/issues/<slug:issue_number>/
newsfeed/subscribe/
newsfeed/subscribe/confirm/<uuid:token>/
newsfeed/unsubscribe/
Templates
The basic templates are provided for all the views and emails with django-newsfeed
.
You can override the templates to add your own design.
Just add newsfeed
directory inside your templates directory
add templates with the same name as the showed tree below.
more on template overriding on the django docs
_
.. _django docs: https://docs.djangoproject.com/en/3.1/howto/overriding-templates/
Template Tree for django-newfeed
:
.. code-block::
templates
└── newsfeed
├── base.html
├── email
│ ├── email_verification.html
│ ├── email_verification_subject.txt
│ ├── email_verification.txt
│ └── newsletter_email.html
├── issue_detail.html
├── issue_list.html
├── issue_posts.html
├── latest_issue.html
├── messages.html
├── newsletter_subscribe.html
├── newsletter_subscription_confirm.html
├── newsletter_unsubscribe.html
└── subscription_form.html
Subscription confirmation Email
We send subscription confirmation email to the new subscribers. you can override these template to change the styles:
.. code-block::
templates
└── newsfeed
├── email
│ ├── email_verification.html
│ ├── email_verification_subject.txt
│ ├── email_verification.txt
Admin Actions
These actions are available from the admin panel:
send newsletters
action should be overridden to use a background task queue.example project
_ to see an example using celery)Send Email Newsletter
We provide a class to handle sending email newsletters to the subscribers. We do not provide any background task queue by default. But it is fairly easy to set it up.
See the example project
_ to see an example using celery
and celery-beat
.
You can override this template to change the style of the newsletter:
.. code-block::
templates
└── newsfeed
├── email
│ └── newsletter_email.html
.. _example project: https://github.com/saadmk11/test-django-newsfeed
The below settings are available for django-newsfeed
.
Add these settings to your projects settings.py
as required.
NEWSFEED_SITE_BASE_URL
http://127.0.0.1:8000
(your sites URL)This settings is required. You need to add your websites URL here in production. This is used to generate confirmation URL and unsubscribe URL for the emails.
NEWSFEED_EMAIL_CONFIRMATION_EXPIRE_DAYS
This settings tells django-newsfeed
to expire the confirmation link in specified number of days.
NEWSFEED_EMAIL_BATCH_SIZE
This settings is helpful when there are a lot of subscribers.
This settings tells django-newsfeed
to send the specified number of emails per batch.
if its zero (0
) then all of the emails will be sent together.
NEWSFEED_EMAIL_BATCH_WAIT
This settings tells django-newsfeed
how long it should wait between
each batch of newsletter email sent.
NEWSFEED_SUBSCRIPTION_REDIRECT_URL
/newsfeed/issues/
This is only required if you are not using ajax
request on the subscription form.
The JavaScript
code for ajax
is included with django-newsfeed
and on by default.
NEWSFEED_UNSUBSCRIPTION_REDIRECT_URL
/newsfeed/issues/
This is only required if you are not using ajax
request on the unsubscription form.
The JavaScript
code for ajax
is included with django-newsfeed
and on by default.
django-newsfeed
sends several signals for various actions.
You can add receivers
to listen to the signals and
add your own functionality after each signal is sent.
To learn more about signals
refer to django Signals Documentation
_.
.. _Signals Documentation: https://docs.djangoproject.com/en/3.1/topics/signals/
newsfeed.signals.email_verification_sent(instance)
Sent after email verification is sent, with Subscriber
instance.
newsfeed.signals.subscribed(instance)
Sent after subscription is confirmed, with Subscriber
instance.
newsfeed.signals.unsubscribed(instance)
Sent after unsubscription is successful, with Subscriber
instance.
See CONTRIBUTING.rst <https://github.com/saadmk11/django-newsfeed/blob/master/CONTRIBUTING.rst>
_
for information about contributing to django-newsfeed
.
The code in this project is released under the GNU General Public License v3.0
_
.. _GNU General Public License v3.0: https://github.com/saadmk11/django-newsfeed/blob/master/LICENSE