I have a list of my all posts:
def posts_list(request):
posts = Post.objects.all()
return render_to_response('posts.html', {'posts':posts},context_instance=RequestContext(request))
in template:
{% for p in posts %}
{{ p.name }}
{% endfor %}
I want post after clicking on its name shows box(div) with all information about this post(Post model: name, content, date, author)
How to do it using jquery(ajax)?
Thank you for your interest.
You’ll need to add an additional view:
new view:
You’ll need to create a post_info.html that gives more information about a post.
in your posts template:
then you’d have the following Javascript (using Jquery in this example)
This will replace the contents of the span with class more_info with the data from the server.
Edit: You’ll also need to add something to your
urls.pyfile, withname= "post_content"set.