1๐
โ
I think you shouldnโt mix in the same time the post form, template tags and Ajax excepted if your notifications are coming from the two ways (template-views and Ajax). If i was you I would do everything with Ajax+javascript only.
Replace your form with just a button containing a function in โonclickโ attribute which will do the Ajax call to your notification view then update you div tag with the success callback.
<script>
function loadNotification() {
$.get( "/url/to/notifications", function( data ) {
$( "#notify-form" ).html( data );
});
}
</script>
<input id="clickMe" type="button" value="clickme" onclick="loadNotification();" />
Also, I would use GET request instead of POST.
I hope I am clear enough ๐
๐คsamidarko
0๐
I urge you to look at the Django messages framework, rather than write your own notification application. It is trivial to hook it up to a $.get()
when necessary.
๐คken
- [Answer]-Django admin custom view and urls
- [Answer]-'dict' object has no attribute 'save' POST doesn't work
- [Answer]-How to set name in SelectDateWidget on buttons for month, year and day?
- [Answer]-Django form, Validate field dynamically
- [Answer]-Why does values query set not match model attributes
Source:stackexchange.com