Package: django-newsfeed
django-newsfeed.. 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-ciWhat is django-newsfeed?django-newsfeedis 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.FeaturesCreate monthly, weekly or daily issues withdraftissue support.Create posts with different categories.Archive and display all of the issues in your website.Newsletter e-mail subscription (ajaxsupport) with e-mail verification.Newsletter e-mail unsubscription (ajaxsupport).Sending newsletters for each issue to all the subscribers.Fully customizable templates.Uses Django's internal tools for sending email.Efficient mass mailing support.RequirementsPython: 3.6, 3.7, 3.8, 3.9, 3.10Django: 2.2, 3.0, 3.1, 3.2, 4.0Example ProjectYou can view the example project for this packagehere_.
This is a news-curator and newsletter subscription application that only uses this package.
It also usescelery,celery-beatandredisto send email newsletters in the background.
The styles in the example project usesbootstrap... _here:https://github.com/saadmk11/test-django-newsfeedDocumentationInstallationInstalldjango-newsfeedusing pip:.. code-block:: shpip install django-newsfeedThen addnewsfeedto yourINSTALLED_APPS:.. code-block:: pythonINSTALLED_APPS = [
    ...
    'newsfeed',
]Then addnewsfeedto your projectsurls.py:.. code-block:: pythonurlpatterns = [
    ...
    path('newsfeed/', include('newsfeed.urls', namespace='newsfeed')),
    ...
]UsageAvailable viewsWe provide these views out of the box: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/TemplatesThe basic templates are provided for all the views and emails withdjango-newsfeed.
You can override the templates to add your own design.Just addnewsfeeddirectory inside your templates directory
add templates with the same name as the showed tree below.
more on template overriding on thedjango docs_.. _django docs:https://docs.djangoproject.com/en/3.1/howto/overriding-templates/Template Tree fordjango-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.htmlSubscription confirmation EmailWe 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.txtAdmin ActionsThese actions are available from the admin panel:publish issues:The selected issues will be published.mark issues as draft:The selected issues will be marked as draft.hide posts:The selected posts will be hidden from the issues.make posts visible:The selected posts will visible on the issues.send newsletters:Sends selected newsletters to all the subscribers.
(send newslettersaction should be overridden to use a background task queue.
See theexample project_ to see an example using celery)Send Email NewsletterWe 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 theexample project_ to see an example usingceleryandcelery-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-newsfeedSettings ConfigurationThe below settings are available fordjango-newsfeed.
Add these settings to your projectssettings.pyas required.NEWSFEED_SITE_BASE_URLdefault:http://127.0.0.1:8000(your sites URL)required: TrueThis 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_DAYSdefault: 3 (after number of days confirmation link expires)required: FalseThis settings tellsdjango-newsfeedto expire the confirmation link in specified number of days.NEWSFEED_EMAIL_BATCH_SIZEdefault: 0 (number of emails per batch)required: FalseThis settings is helpful when there are a lot of subscribers.
This settings tellsdjango-newsfeedto send the specified number of emails per batch.
if its zero (0) then all of the emails will be sent together.NEWSFEED_EMAIL_BATCH_WAITdefault: 0 (in seconds)required: FalseThis settings tellsdjango-newsfeedhow long it should wait between
each batch of newsletter email sent.NEWSFEED_SUBSCRIPTION_REDIRECT_URLdefault:/newsfeed/issues/required: FalseThis is only required if you are not usingajaxrequest on the subscription form.
TheJavaScriptcode forajaxis included withdjango-newsfeedand on by default.NEWSFEED_UNSUBSCRIPTION_REDIRECT_URLdefault:/newsfeed/issues/required: FalseThis is only required if you are not usingajaxrequest on the unsubscription form.
TheJavaScriptcode forajaxis included withdjango-newsfeedand on by default.Signalsdjango-newsfeedsends several signals for various actions.
You can addreceiversto listen to the signals and
add your own functionality after each signal is sent.
To learn more aboutsignalsrefer to djangoSignals Documentation_... _Signals Documentation:https://docs.djangoproject.com/en/3.1/topics/signals/Subscriber Signalsnewsfeed.signals.email_verification_sent(instance)Sent after email verification is sent, withSubscriberinstance.newsfeed.signals.subscribed(instance)Sent after subscription is confirmed, withSubscriberinstance.newsfeed.signals.unsubscribed(instance)Sent after unsubscription is successful, withSubscriberinstance.ContributeSeeCONTRIBUTING.rst <https://github.com/saadmk11/django-newsfeed/blob/master/CONTRIBUTING.rst>_
for information about contributing todjango-newsfeed.LicenseThe code in this project is released under theGNU General Public License v3.0_.. _GNU General Public License v3.0:https://github.com/saadmk11/django-newsfeed/blob/master/LICENSE