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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:48:57+00:00 2026-06-13T05:48:57+00:00

I have a django project using the built in user model. I need to

  • 0

I have a django project using the built in user model.

I need to add relationships to the user. For now a “like” relationship for articles the user likes and a “following” relationship for other users followed.

What’s the best way to define these relationships? The django doc recommends creating a Profile model with a one on one relation to the user to add fields to the user. but given no extra fields will be added to the user profile in my case this is overkill.

Any suggestions?

  • 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-13T05:48:58+00:00Added an answer on June 13, 2026 at 5:48 am

    For these special many-to-many relationships, you have to define them in models:

    class UserFollowing(models.Model):
        user = models.ForeignKey(User, related_name='following')
        following = models.ForeignKey(User, related_name='followed_by')
    

    So then if you have a user, you can do things like:

    user = User.objects.get(...)
    user.following.all() # all users this user is following
    user.followed_by.all() # all users who follow this user
    

    As for articles, you have setup a similar schema:

    class ArticleLike(models.Model):
        article = models.ForeignKey(Article, related_name='likes')
        like = models.ForeignKey(User, related_name='articles_like')
    
    Article.objects.get(...).likes.all()
    
    User.objects.get(...).articles_like.all()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we have just started using a git account of our Django website project so
I have a django project which is laid out like this... myproject apps media
I have a Django project for managing a list of journal articles. The main
I have a django auth user proxy model that has some extra permissions attached
I have a Django project using https for certain part of the url (/account/,
So, I have a django project that is using jinja2 rendering, and I also
I am configuring django on CentOS. i have made a project using command django-admin.py
I have a Django project for a simple blog/forum website I’m building. I’m using
I have a django project using multiple databases. I am using django-nose as the
Brand new to django. We have a legacy django project using django 0.96x that

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.