Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django Message Framework #3

Closed
infosrabah opened this issue Aug 26, 2018 · 8 comments
Closed

Django Message Framework #3

infosrabah opened this issue Aug 26, 2018 · 8 comments

Comments

@infosrabah
Copy link

Hi,

We can't use django framework messages unless, it has to redirect to the success_url of the class responsible for the form...

I guess it is javascript who take care of the rest when the form_is_valid not django class ??
any idea. how to achieve it ?

thank you

@dimkoug
Copy link
Owner

dimkoug commented Aug 26, 2018

In the class based view for example in the CreateView in the form_valid method you can add a message for example "the object saved". Read the django documentation about messages framework on how to do it.

@infosrabah
Copy link
Author

infosrabah commented Aug 31, 2018

Hi dimkoug thatnk's for the answer,

Actually it does work, I used :

class TodoCreateView(SuccessMessageMixin, AjaxCreateView, CmsCreateView):
...
	success_url = reverse_lazy('todo:todoList')
	success_message = _("<strong>ToDo</strong> added successfully.")
...

But after you refresh the page with is not very great to be step ahead of a message, I mean when you create the "Todo" it refresh the list (not the page), and if you go to somewhere or another page you got the message. !!

is there a way to overide the refresh list to refresh the page, I mean let the Create Class View handle the redirection to success_url ??? not just refrech the table list. but the whole page redirection.

Please Help

Thank you.

@dimkoug
Copy link
Owner

dimkoug commented Aug 31, 2018

Hello infosrabah, the class based view by default redirects to the success_url. You can read more about the classed based views in the django documentation. The purpose of this application i wrote is to override the default django behaviour and to give ajax, modal popup functionallity to the class based views. If you want full page reload use the default class based views of the django framework.

@infosrabah
Copy link
Author

infosrabah commented Aug 31, 2018

I know that class based view redirect by default, that the behaviour that I want it, and I was so amazed about the functionnality of this project like Modals (Amazing), but I'm knida into the middle : Modal for the ajax form and success_url redirection for the django message framework, I need to see the message if a CRUD happend.

And I already read about it in doc, my question is how to override your Ajax refresh list to get it back to django success_url once the form is valid ?

is there some kind of code , can you tell me what should I do, what code should I change,

My knowledge in Ajax and jQuery are very limited I'm sorry (almost None). and the fact that this is your project you certenly now how to make it work that way .!

I need that functionnality (Modal Ajax + Django message), there's a project in github also, but there's a problem with Django message, but your project alreasy shows the message , but the problem is to refresh the page (a real get http) not the table.

Please.

@dimkoug
Copy link
Owner

dimkoug commented Aug 31, 2018

Remove the AjaxCreateView and try again. Read the django documentation the class based views section.

@dimkoug dimkoug closed this as completed Aug 31, 2018
@infosrabah
Copy link
Author

infosrabah commented Aug 31, 2018

I did, the request went well :

31/Aug/2018 14:48:42] "GET /todo/todo/todo/add/ HTTP/1.1" 200 4293

But the Moldal won't show up !! ??

Any idea ?

@dimkoug
Copy link
Owner

dimkoug commented Aug 31, 2018

The modal shows when you Have the ajaxCreateView. So if you want both you have to show or hide the messages via ajax. I don't have that functionallity in my project.

@infosrabah
Copy link
Author

Is that hard to implement, can you point me to how you do it ?

If it is hard, thank you, I will drop it.

thank you dimkoug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants