Package: django-drip-campaigns
Django Drip CampaignsDrip campaigns are pre-written sets of emails sent to customers or prospects over time. Django Drips lets you use the admin to manage drip campaign emails using querysets on Django's User model.This project is a fork of the one written byZapier.You can check out the docshere.Installation:Install django-drip-campaings using pip:pip install django-drip-campaignsAdd'drip'to yourINSTALLED_APPSlist on your settings.INSTALLED_APPS=['django.contrib.contenttypes','django.contrib.comments','django.contrib.sessions','django.contrib.sites','django.contrib.admin',# ...'drip',](Optional) SetDRIP_FROM_EMAIL = '<your_app_from_email>'in your settings, where<your_app_from_email>is the email account that is going to be shown in the sent emails. OtherwiseEMAIL_HOST_USERvalue will be used.Finally, runpython manage.py migrate dripto set up the necessary database tables.UsageIf you haven't, create a superuser with theDjango createsuperuser command. Login with the admin user, and selectDripsto manage them. You will be able to:View created drips.Create a new drip.Select and delete drips.Now you can also manage campaigns, selectCampaignsto manage them. You will be able to:View created campaigns.Create a new campaign.Select and delete campaign.Create CampaignIn the Django admin, after selectCampaigns, you can click onADD CAMPAIGN +button to create a new one. You will see theadd campaignpage:When you create a campaign, you need to decide if the related drips will be deleted along with the campaign, using theDelete dripsfield.Here you will find an inline creation or edition forDripsthis will not include theQUERY SET RULESsection. It will only allow you to change the mail content in the Drip.Campaigns will allow you to manage many Drips that need to be related between them.Create DripIn the Django admin, after selectDrips, you can click onADD DRIP +button to create a new one. You will see theadd drippage:Here you can relate the Drip to the correspondingCampaign. Grouping several drips under a campaign.On theFIELD NAME OF USERinput, when you click on it, you will be able to view:The fields of your user's model.The fields of your user's model in other models that are related with it.Please take a look a this example:With this, you can select one or more fields to create useful drips.
Additionally if you select a field name of user that has a date type, you can enter in theFIELD VALUEinput, a date value written in natural language that combines operations on the current datetime.
For example, if you have selected the fieldlast_loginthat has a date type, and you want to create a drip to send emails to the users who logged in exactly one week ago; you can enter:now-1 weekornow- 1 wPossible operations and values:Add (+) or subtract (-) dates.On the left side of the operation, write the current datetime value:now.On the right side of the operation:secondsors.minutesorm.hoursorh.daysord.weeksorw.If you enter the number1, you can writesecond,minute, etc.Don't enter a space betweennowand the operation symbol. Optionally you can add (or not) a space around the number value.Let's see some examples of the date values that you can enter:now-1 daynow+ 8daysnow+ 1 hnow-4hoursnow- 3 weeksnow-1 weeksView TimelineIn the Django admin, you can select a drip and then click on theVIEW TIMELINEbutton to view the mails expected to be sent with the corresponding receivers:Send dripsTo send the created and enabled drips, run the command:python manage.py send_dripsYou can use cron to schedule the drips.The cron schedulerYou may want to have an easy way to send drips periodically. It's possible to set a couple of parameters in your settings to do that. First activate the scheduler by adding theDRIP_SCHEDULE_SETTINGSdictionary:# your settings fileDRIP_SCHEDULE_SETTINGS={'DRIP_SCHEDULE':True,}After that, choose:A day of the week: An integer value between0-6, or a string:'mon','tue','wed','thu','fri','sat','sun'. The name in the settings isDRIP_SCHEDULE_DAY_OF_WEEK(default is set to0).An hour: An integer value between0-23. The name in the settings isDRIP_SCHEDULE_HOUR(default is set to0).A minute: An integer value between0-59. The name in the settings isDRIP_SCHEDULE_MINUTE(default is set to0).With those values, a cron scheduler will execute thesend_dripscommand every week in the specified day/hour/minute. The scheduler will use the timezone of yourTIME_ZONEparameter in your settings (default is set to'UTC'). For example, if you have:DRIP_SCHEDULE_SETTINGS={'DRIP_SCHEDULE':True,'DRIP_SCHEDULE_DAY_OF_WEEK':'mon','DRIP_SCHEDULE_HOUR':13,'DRIP_SCHEDULE_MINUTE':57,}Then every Monday at 13:57 thesend_dripscommand will be executed.
Last but not least, add this line at the end of your mainurls.pyfile to start the scheduler:# your main urls.py file...fromdrip.scheduler.cron_schedulerimportcron_send_drips...cron_send_drips()We recommend you to do it there because we know for sure that it's a file that is executed once at the beginning.Some tips:If you want to run the command every day in the week, hour, or minute, just set the corresponding parameter to'*'.If you want to run the command more than a day in the week, just set theDRIP_SCHEDULE_DAY_OF_WEEKto more than one value. For example, if you set that to'mon-fri'the command will be executed from Monday to Friday.Celery integrationIMPORTANT: We use Celery 5.2.2 that supports Django 1.11 LTS or newer versions.If you need to use celery it can be configured in the same way you just need to add the following keySCHEDULERsetted as"CELERY":DRIP_SCHEDULE_SETTINGS={'DRIP_SCHEDULE':True,'DRIP_SCHEDULE_DAY_OF_WEEK':'mon','DRIP_SCHEDULE_HOUR':13,'DRIP_SCHEDULE_MINUTE':57,'SCHEDULER':"CELERY",}The default value of this key is"CRON", if you enableDRIP_SCHEDULEit will work with a Cron by default.In order to make this happen, the project'scelery.pysetup shall invoke theautodiscoverttasksfunction. This task is scheduled with a simpleCelery beat configuration.