Vlad
Vlad

Reputation: 1

How i can create user alerts in Django?

Subj

Several limitations:

It remains only to consider how to store it in a database, and generate and transmit to the template.

Examples of alerts:

User <a href="/accounts/64/profile/"> Vlad </ a> commented on your
forum <a href="/forum/topic/54/"> Topic </ a>.

User <a href="/accounts/64/profile/"> Vlad </ a> added to your account to your favorites.

User <a href="/accounts/64/profile/"> Vlad </ a> asks if you add to your favorites.
<form action="" method="POST">
<input type="submit" value="Ok">
<input type="submit" value="No">
</ form>

Anybody can explain how to store it in a database, and generate and transmit to the template?

Sorry for my Engl

Upvotes: 0

Views: 2230

Answers (3)

Atul Jain
Atul Jain

Reputation: 1055

I think you should use django-alerts library for Send alerts, notifications, and messages based on events (signals) in your django application

installation of alerts

pip install django-alert

for more information about alert you can try this link DJANGO-ALERTS

for storing it into the database you can create seperate table/collection and there you can generate schema like user recived , user logged in etc.

Upvotes: 0

Dracontis
Dracontis

Reputation: 4384

I think you will need to create one more table, where you will keep data about the user who will recieve alert, user who will send alert and template name, where you will keep alert (so you will need to include it in your main template). Also, you will need one or more boolean fields for flagging this alerts.

So, every time user log in or change page you will check this table and show alerts. If there any, you'll display alert block and put flag into False. So, I think you will need more flags, because one flag will check views of this alert, other will check user answer (like last one form) and so on.

Upvotes: 0

Shawn Chin
Shawn Chin

Reputation: 86994

You could use, or build on, the Django Messages Framework.

Upvotes: 1

Related Questions