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

  • Home
  • SEARCH
  • 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 5944889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:36:14+00:00 2026-05-22T16:36:14+00:00

I am creating a form where a someone enters a network , location ,

  • 0

I am creating a form where a someone enters a network, location, and administrators of the network. This is my model —

class Administrator(models.Model):
    email = models.EmailField()
    name = models.CharField(max_length=100, blank=True)

class Network(models.Model):
    name = models.CharField(max_length=50)
    location = models.CharField(max_length=50)
    administrators = models.ManyToManyField(Administrator, blank=True)

How could I create a form such that when the site admin adds an administrator to a network, it will immediately create that entry in the Administrator class and then link up to that in the administrators column?

  • 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-22T16:36:14+00:00Added an answer on May 22, 2026 at 4:36 pm

    For custom processing of your form objects use form.save(commit=False):

    This save() method accepts an optional
    commit keyword argument, which accepts
    either True or False. If you call
    save() with commit=False, then it will
    return an object that hasn’t yet been
    saved to the database. In this case,
    it’s up to you to call save() on the
    resulting model instance. This is
    useful if you want to do custom
    processing on the object before saving
    it, or if you want to use one of the
    specialized model saving options.

    from: https://docs.djangoproject.com/en/1.0/topics/forms/modelforms/#the-save-method


    So if you have a NetworkForm you could use commit=False and then check if your administrator already exists or if he needs to be created. get_or_create is really handy for this.

    Then you could set administrator on your form to the newly created or fetched administrator-instance and save the form (using form.save() and form.save_m2m()).

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

Sidebar

Related Questions

After creating a new form, I usually perform this ritual: Change the name into
Someone can explain this error? Error Creating Control - head Object reference not set
When creating a form using three20 components with the methodology found in this example
I am currently creating a class to handle all my form data which will
I have a form used for creating a team (the model is Team). The
Eariler I happily used the following code for creating form elements (inside Zend_Form descendant):
I'm creating a form using the Content Construction Kit (CCK) in Drupal5. I've added
I am creating a form in HTML that will be printed, with fields that
I am creating a form where a user will register with a struts2 application.
I am creating a form designer. It will generate PHP code which will produce

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.