It's cool. Thank you!

понедельник, 19 февраля 2018 г., 15:21:31 UTC+3 пользователь Etienne 
Robillard написал:
>
> Check this out: 
> https://stackoverflow.com/questions/20306981/how-do-i-integrate-ajax-with-django-applications
>
> Etienne
>
> Le 2018-02-19 à 07:12, Mike Ru a écrit :
>
> I don't get how to do it. I need to display a message "Hello world"  
> using  framawork messages with Jquery/Ajax 
> I can do it without Jquery/Ajax but it's not good.
> The user clicks the link and depending on a condition or to send him 
> according to the reference or to display the message without rebooting the 
> page.
>
> Here is my code:
> views.py
> from django.shortcuts import render, HttpResponseRedirect
> from django.contrib import messages
>
> def foo(request):
>     print('I am foo')
>     spam = 0
>     if spam != 10:
>         messages.info(request, 'Hellow world')
>         return HttpResponseRedirect('/')
>     return render(request, 'app/foo.html')
>
> def index(request):
>     return render(request, 'app/index.html')
>
> index.html
> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
> "></script>
> <p>I'm index.html</p>
>     <a href="{% url 'foo' %}" id="mylink">link</a>
>     <!-- <a href="" id="mylink" class="alert">link</a> -->
>
>     {% for message in messages %}
>         {{ message }}
>     {% endfor %}
>
> foo.html
>  <p>I am link.html</p>
>
> How can I do it with Jquery/Ajax? Help me, please!
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@googlegroups.com <javascript:>.
> To post to this group, send email to django...@googlegroups.com 
> <javascript:>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/86dffe89-0338-475e-a196-d3cb18ff651c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/django-users/86dffe89-0338-475e-a196-d3cb18ff651c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
> -- 
> Etienne robillardtka...@yandex.com 
> <javascript:>https://www.isotopesoftware.ca/
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d58f057f-d127-4d9c-8976-b91b88cd7ab0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to