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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:11:15+00:00 2026-05-31T05:11:15+00:00

I am trying to create a model instance that includes a list of model

  • 0

I am trying to create a model instance that includes a list of model via many-to-many field via ModelForm. However when this occurs, I need to be able to change one of the fields being referenced.

Here is the stripped code:

class AllAtt(models.Model):
    weighting = models.IntegerField(null=True,blank=True)
    mass = models.IntegerField(null=True,blank=True)
    required_Power = models.IntegerField(null=True,blank=True)
    memory = models.IntegerField(null=True,blank=True)

class Mission(AllAtt):
    name = models.CharField(max_length=50)
    def __unicode__(self):
        return self.name

class Scenario(models.Model):
    name = models.CharField(max_length=50)
    creation_date = models.DateTimeField(default=datetime.now)
    creator = models.ForeignKey(User,null=True,blank=True)
    mission = models.ManyToManyField(Mission)
    def __unicode__(self):
        return self.name

class ScenarioForm(ModelForm):
    class Meta:
        model = Scenario
        fields = ('name','mission',)

Where the Missions instances are imported from a database. Currently this allows me to pick Mission instances from the multiplechoicefield, however this isn’t what I need. I want to be able to include all of the Mission instances in the Scenario and then change the “weighting” field through the form.

A simple example of what I am trying to do:
I have a certain number of tasks (Missions) and when combined they accomplish something (Scenario).
A human has a lot of task functions. If my Scenario is “Getting ready for a date” then these functions may be weighted in importance as:
Make coffee – 0, Feed dog -2, Shower – 3, Get dressed – 5. Whereas if the Scenario is “Working on Django code” these functions are weighted as: Make coffee – 5, Feed dog – 2, Shower – 0, Get dressed – 1. And each time I make a new Scenario I need to be able to change the weights of all the possible tasks.

Any help or insight on how to accomplish this would be greatly appreciated. Thanks!

  • 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-31T05:11:16+00:00Added an answer on May 31, 2026 at 5:11 am

    As I understand you need to specify weight on Mission relations in Scenario.

    Basically what you need is through Model (with weight). You can see it documented here: https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany

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

Sidebar

Related Questions

In Django, I need to create a model in which an instance of that
I'm trying to create a Django model that handles the following: An Item can
I am trying to create a simple MongooseJS example program that gets a list
I'm trying to create a generic list from a specific Type that is retrieved
I am trying to create the following: User model (this is fine) id Link
I'm trying to create a basic template to display the selected instance's field values,
I'm trying to create a model instance from my code, and I pass all
I'm trying to create an instance of my CompanyLogo model if the hash params[:vacancy]['companies']['company_logo']
I am trying to create an ActiveRecord model called 'Search' without a table. I
I am trying to create a mapping file for the following Model using Fluent

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.