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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:29:08+00:00 2026-05-28T20:29:08+00:00

I want to create a website for students with django. I have learning_plan with

  • 0

I want to create a website for students with django.

I have learning_plan with n subjects

When I create a student I want to choose an existing learning_plan and have automatic all the subjects that the learning_plan has, also I want to have exam_grades different for each student.

What I’ve done so far:

class Subject(models.Model):
    name = models.CharField(max_length=60)

    def __unicode__(self):
        return self.name

class LearningPlan(models.Model):
    name = models.CharField(max_length=60)
    subjects = models.ManyToManyField(Subject, through='Exam')

    def __unicode__(self):
        return self.name

class Student(models.Model):
    name = models.CharField(max_length=60)
    learning_plan = models.ForeignKey(LearningPlan)

    def __unicode__(self):
        return self.name


class Exam(models.Model):
    subject = models.ForeignKey(Subject)
    learning_plan = models.ForeignKey(LearningPlan)
    exam_grade = models.IntegerField()

I know what I want I do not know how to do it. I want to have a plan with Subjects: Subject1, Subject2, Subject3 … and when I add a new student I select a plan and see all the subjects from the grade associated to the student and to can add exam_grade to each of the Subjects (Subeject1, Subject2, Subject3 …) and the grades for the same subject to be different for different students. I do not know how to implement this.

  • 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-05-28T20:29:08+00:00Added an answer on May 28, 2026 at 8:29 pm

    If you have a student and what to get his (her) subjects, use this:

    student.learning_plan.subjects.all()
    

    Exam grades are simple too, but it’s better to add related_name first:

    class Exam(models.Model):
        subject = models.ForeignKey(Subject)
        learning_plan = models.ForeignKey(LearningPlan, related_name='exams')
        exam_grade = models.IntegerField()
    

    Now you can get student’s exams:

    student.learning_plan.exams.all()
    

    And if you want to add an exam, it’s still simple:

    new_exam = Exam.objects.create(subject=some_subject, learning_plan=some_lp, exam_grade=98)
    student.learning_plan.exams.add(new_exam)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a website scrolled vertically. The problem I have is that
Let's say I want to create a website that contains one page. All the
I want to create a website with various users. The users can have different
Im a Drupal beginner. I want to create a simple website, which has a
I have a website which uses PHP and HTML pages, I want to create
I want to create an interactive website using aspx and ajax, that there will
I want to create a donation form on my website that forwards donors to
I want to create a website that the login system shouldn't be handled by
I want to create a website that allows me to sketch something in real
I want to create website thumbnails (screenshots) using php. I have a dedicated server

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.