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 8438839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:49:43+00:00 2026-06-10T07:49:43+00:00

there is a blog project. its working correctly now. there will be multiple users.

  • 0

there is a blog project. its working correctly now. there will be multiple users.

i want to list posts which are created by user that logged in right now. if ‘x’ user log in , he must see just his own posts on admin page.

what is the correct way for this ?

here is my models.py:

class Post(models.Model):
    title = models.CharField(max_length = 100)
    body = models.TextField()
    slug = AutoSlugField(populate_from='title',unique=True)
    posted = models.DateField(auto_now_add=True)
    isdraft = models.BooleanField(default=False)

    def __unicode__(self):
        return self.title()

    @permalink
    def get_absolute_url(self):
        return ('view_blog_post',None, {'postslug':self.slug})


class UserProfile(models.Model):
    user = models.OneToOneField(User)

def create_user(sender,instance,created,**kwargs):
    if created:
        UserProfile.objects.create(user=instance)

post_save.connect(create_user, sender=User)

and my views.py ( just part of admin page ) :

@login_required(login_url='/panel/')
def adminView(request):
    if request.session['loggedin']=="djangoo":

        draft_list = Post.objects.filter(isdraft=True).order_by("-posted")
        p_draft = Paginator(draft_list,15)

        publish_list = Post.objects.filter(isdraft=False).order_by("-posted")
        p_publish = Paginator(publish_list,15)

        page = request.GET.get('page')

        try:
            post_d = p_draft.page(page)
            post_p = p_publish.page(page)
        except PageNotAnInteger:
            post_d = p_draft.page(1)
            post_p = p_publish.page(1)
        except EmptyPage:
            post_d = p_draft.page(p_draft.num_pages)
            post_p = p_publish.page(p_publish.num_pages)


        return render_to_response('admin.html',
                                  {'draft_list':draft_list,'publish_list':publish_list,'post_d':post_d,'post_p':post_p},
                                 context_instance=RequestContext(request))
    else:
        HttpResponseRedirect('/panel/')

thank you.

  • 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-10T07:49:45+00:00Added an answer on June 10, 2026 at 7:49 am

    You have to store user which posted it in your post model and then you can easily filter out those.

    I would update model like:

    class Post(models.Model):
        owner = models.ForeignKey('User')
        # your other fields
    

    And admin view :

    @login_required(login_url='/panel/')
    def adminView(request):
        draft_list = Post.objects.filter(owner=request.user).filter(isdraft=True).order_by("-posted")
        #------------------------------^^^^ filter based on owner
        p_draft = Paginator(draft_list,15)
    
        publish_list = Post.objects.filter(owner=request.user).filter(isdraft=False).order_by("-posted")
        p_publish = Paginator(publish_list,15)
        #your other view code
        ...
    

    Also, you will have to update the view which adds a post to put owner as well.

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

Sidebar

Related Questions

I am currently working on a codeigniter project, now i want a option Blog
There's a blog post comment on codinghorror.com by Paul Jungwirth which includes a little
I am working on a Wordpress blog where there is going to be an
I want to start a new project, there are currently 4 of us who
I created a MVC application which is working fine in the local host. I
I've been working on an ASP.NET MVC project for about 8 months now. For
In Suzanne Cook's blog there is such a description: LoadFrom Context: In general, if
There is a blog post on Why Windows Mobile's X button doesn't close the
I have a recipe blog and there is an option to print just the
I was reading on a blog that there's a GLImageProcessing example from apple. I

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.