Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8663523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:00:23+00:00 2026-06-12T17:00:23+00:00

I have a list of my all posts: def posts_list(request): posts = Post.objects.all() return

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:00:25+00:00Added an answer on June 12, 2026 at 5:00 pm

    You’ll need to add an additional view:

    new view:

    def post_content(request, post_id):
        post = get_object_or_404(Post, id = post_id)
        return render_to_response('post_info.html', {'post':post},context_instance=RequestContext(request))
    

    You’ll need to create a post_info.html that gives more information about a post.

    in your posts template:

    {% for p in posts %}
         <span data-url='{% url post_content post_id=p.id %}' class='post'>{{ p.name }}<span class='more_info'></span></span>
    {% endfor %}
    

    then you’d have the following Javascript (using Jquery in this example)

    $(document).ready( function () {
    $('.post').on('click', function() {
        var span = $(this);
        $.ajax({
         url: span.attr('data-url')
        }).done(function(data) {
             span.find('.more_info').html(data);
         });
    });
    });
    

    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.py file, with name= "post_content" set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of objects and I want to remove all the ones
I have the following python code. class MainPage(BaseHandler): def post(self, location_id): reservations = self.request.get_all('reservations')
I have a List<List<String>> I need to get a List of all possible concatenation
I have a PhoneGap app, where I need to list all the user's friends,
In my directory I have subfolders, and I want to list all directories like
I have a list of 400 strings that all end in _GONOGO or _ALLOC.
I have a list of calling codes for all countries(the phone number prefixes), I
I have a list activity which display all running applications in the device. it's
I have a list of lists and want to replace all the occurrences of
I have a list: Collection users which has around 100K+ records of users (all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.