How to display messages using the messages framework in Django using a background job?











up vote
0
down vote

favorite












I am running background tasks in my Django app using Django Background Tasks, which is checking from a Django model if a particular deadline is crossed.



@background(schedule=10000)
def check_deadline(repeat=30000):
# Check if deadline has crossed from DB
# Return the record's title whose deadline has crossed


If the condition is satisfied, then the background task must send a message to any template that is being currently viewed. I am not sure how to send a message to the template from the background task.










share|improve this question






















  • That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
    – Daniel Roseman
    Nov 4 at 10:17










  • Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
    – Sushant Kumar
    Nov 4 at 10:20










  • You can use django channels. It may help you.
    – a_k_v
    Nov 4 at 10:21










  • Or firebase or amazon SNS
    – a_k_v
    Nov 4 at 10:22















up vote
0
down vote

favorite












I am running background tasks in my Django app using Django Background Tasks, which is checking from a Django model if a particular deadline is crossed.



@background(schedule=10000)
def check_deadline(repeat=30000):
# Check if deadline has crossed from DB
# Return the record's title whose deadline has crossed


If the condition is satisfied, then the background task must send a message to any template that is being currently viewed. I am not sure how to send a message to the template from the background task.










share|improve this question






















  • That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
    – Daniel Roseman
    Nov 4 at 10:17










  • Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
    – Sushant Kumar
    Nov 4 at 10:20










  • You can use django channels. It may help you.
    – a_k_v
    Nov 4 at 10:21










  • Or firebase or amazon SNS
    – a_k_v
    Nov 4 at 10:22













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am running background tasks in my Django app using Django Background Tasks, which is checking from a Django model if a particular deadline is crossed.



@background(schedule=10000)
def check_deadline(repeat=30000):
# Check if deadline has crossed from DB
# Return the record's title whose deadline has crossed


If the condition is satisfied, then the background task must send a message to any template that is being currently viewed. I am not sure how to send a message to the template from the background task.










share|improve this question













I am running background tasks in my Django app using Django Background Tasks, which is checking from a Django model if a particular deadline is crossed.



@background(schedule=10000)
def check_deadline(repeat=30000):
# Check if deadline has crossed from DB
# Return the record's title whose deadline has crossed


If the condition is satisfied, then the background task must send a message to any template that is being currently viewed. I am not sure how to send a message to the template from the background task.







python django django-models django-templates background-process






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 4 at 10:12









Sushant Kumar

93111




93111












  • That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
    – Daniel Roseman
    Nov 4 at 10:17










  • Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
    – Sushant Kumar
    Nov 4 at 10:20










  • You can use django channels. It may help you.
    – a_k_v
    Nov 4 at 10:21










  • Or firebase or amazon SNS
    – a_k_v
    Nov 4 at 10:22


















  • That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
    – Daniel Roseman
    Nov 4 at 10:17










  • Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
    – Sushant Kumar
    Nov 4 at 10:20










  • You can use django channels. It may help you.
    – a_k_v
    Nov 4 at 10:21










  • Or firebase or amazon SNS
    – a_k_v
    Nov 4 at 10:22
















That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
– Daniel Roseman
Nov 4 at 10:17




That doesn't make sense. Your job is running on the background, it's not associated with any request. Whose template would you send it to?
– Daniel Roseman
Nov 4 at 10:17












Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
– Sushant Kumar
Nov 4 at 10:20




Is there no provision for the server to push messages to the frontend, no matter which template is being displayed?
– Sushant Kumar
Nov 4 at 10:20












You can use django channels. It may help you.
– a_k_v
Nov 4 at 10:21




You can use django channels. It may help you.
– a_k_v
Nov 4 at 10:21












Or firebase or amazon SNS
– a_k_v
Nov 4 at 10:22




Or firebase or amazon SNS
– a_k_v
Nov 4 at 10:22

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139686%2fhow-to-display-messages-using-the-messages-framework-in-django-using-a-backgroun%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53139686%2fhow-to-display-messages-using-the-messages-framework-in-django-using-a-backgroun%23new-answer', 'question_page');
}
);

Post as a guest




















































































這個網誌中的熱門文章

Academy of Television Arts & Sciences

L'Équipe

1995 France bombings