[{"data":1,"prerenderedAt":210},["ShallowReactive",2],{"\u002Fposts\u002Fsending-notifications-to-django-users":3,"\u002Fposts\u002Fsending-notifications-to-django-users-surround":200},{"id":4,"title":5,"body":6,"categories":181,"date":183,"description":184,"extension":185,"meta":186,"navigation":108,"path":187,"robots":188,"seo":189,"sitemap":190,"stem":191,"tags":192,"__hash__":199},"posts\u002Fposts\u002Fsending-notifications-to-django-users.md","Sending Notifications to Django Users",{"type":7,"value":8,"toc":176},"minimark",[9,13,17,22,33,68,75,84,87,91,94,138,149,153,156,162,169,172],[10,11,5],"h1",{"id":12},"sending-notifications-to-django-users",[14,15,16],"p",{},"So, you want to notify the user via email or push notification or sms or whatsapp or whatever, after they did something on your website\u002Fapp.",[18,19,21],"h3",{"id":20},"installation","Installation",[14,23,24,25,29,30],{},"Install ",[26,27,28],"code",{},"mad_notifications"," from using ",[26,31,32],{},"pip install mad_notifications",[34,35,40],"pre",{"className":36,"code":37,"language":38,"meta":39,"style":39},"language-python shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","INSTALLED_APPS = [\n    ...\n    'mad_notifications',\n]\n","python","",[26,41,42,50,56,62],{"__ignoreMap":39},[43,44,47],"span",{"class":45,"line":46},"line",1,[43,48,49],{},"INSTALLED_APPS = [\n",[43,51,53],{"class":45,"line":52},2,[43,54,55],{},"    ...\n",[43,57,59],{"class":45,"line":58},3,[43,60,61],{},"    'mad_notifications',\n",[43,63,65],{"class":45,"line":64},4,[43,66,67],{},"]\n",[14,69,70,71,74],{},"update your project's ",[26,72,73],{},"urls.py"," and add",[34,76,78],{"className":36,"code":77,"language":38,"meta":39,"style":39},"path('notifications\u002F', include('mad_notifications.api.urls')),\n",[26,79,80],{"__ignoreMap":39},[43,81,82],{"class":45,"line":46},[43,83,77],{},[14,85,86],{},"Its installed now, what next?",[18,88,90],{"id":89},"basic-usage","Basic Usage",[14,92,93],{},"Call it where you want it.",[34,95,97],{"className":36,"code":96,"language":38,"meta":39,"style":39},"from mad_notifications.shorthand import newNotification\n\nreturn newNotification(\n    user = get_user_model(id=SOME_ID), # django user object\n    title = \"Welcome to my website\u002Fapp\", # string\n    content = \"Thanks for join my website\u002Fapp\", # string\n)\n",[26,98,99,104,110,115,120,126,132],{"__ignoreMap":39},[43,100,101],{"class":45,"line":46},[43,102,103],{},"from mad_notifications.shorthand import newNotification\n",[43,105,106],{"class":45,"line":52},[43,107,109],{"emptyLinePlaceholder":108},true,"\n",[43,111,112],{"class":45,"line":58},[43,113,114],{},"return newNotification(\n",[43,116,117],{"class":45,"line":64},[43,118,119],{},"    user = get_user_model(id=SOME_ID), # django user object\n",[43,121,123],{"class":45,"line":122},5,[43,124,125],{},"    title = \"Welcome to my website\u002Fapp\", # string\n",[43,127,129],{"class":45,"line":128},6,[43,130,131],{},"    content = \"Thanks for join my website\u002Fapp\", # string\n",[43,133,135],{"class":45,"line":134},7,[43,136,137],{},")\n",[14,139,140,141,144,145,148],{},"this will send an email to the user, where the ",[26,142,143],{},"title"," will be the subject and ",[26,146,147],{},"content"," will be the content.",[18,150,152],{"id":151},"push-notification","Push Notification",[14,154,155],{},"So you want to send them a push notification now? Okay I got you.",[14,157,158],{},[159,160,161],"strong",{},"Important: Make sure you have firebase already setup in your project.",[14,163,164,165,168],{},"From your mobile app, generate firebase device token, and post it to ",[26,166,167],{},"\u002Fnotifications\u002Fdevices\u002F"," this will automatically associate the device token with the user, based on the authorization headers.",[14,170,171],{},"Now when you send the notification, it will also send the push notification to that device.",[173,174,175],"style",{},"html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":39,"searchDepth":52,"depth":52,"links":177},[178,179,180],{"id":20,"depth":58,"text":21},{"id":89,"depth":58,"text":90},{"id":151,"depth":58,"text":152},[182],"Development","2022-08-30T00:00:00.000Z","The article helps implementing notification sending to django >=3.2 user(s).","md",{},"\u002Fposts\u002Fsending-notifications-to-django-users",null,{"title":5,"description":184},{"loc":187},"posts\u002Fsending-notifications-to-django-users",[193,194,195,38,196,197,198],"ux","django","cookiecutter","Mad Notifications","notifications","skim it","hXome3VVUvlKdzwKBg-Tm_ErwqpQyhkHX6r4lBczpOI",[201,205],{"title":202,"path":203,"stem":204,"description":202,"children":-1},"How to setup AdMob mediation for better revenue","\u002Fposts\u002Fhow-to-setup-admob-mediation","posts\u002Fhow-to-setup-admob-mediation",{"title":206,"path":207,"stem":208,"description":209,"children":-1},"The quiet revolution reshaping how we build software","\u002Fposts\u002Fsoftware-revolution","posts\u002Fsoftware-revolution","A deep dive into the tools and workflows that are fundamentally changing the craft of programming — and what it means for developers everywhere.",1776339849318]