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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:41:43+00:00 2026-05-20T20:41:43+00:00

Given: from django.db import models class MyModel(models.Model): … owners = models.CharField(max_length=255, blank=False) where owners

  • 0

Given:

from django.db import models
class MyModel(models.Model):
    ...
    owners = models.CharField(max_length=255, blank=False)

where owners is a pipe-separated list of email addresses.

In the page, there are multiple <input> fields with the same name, so the server gets the values in an array.

The HTML code for the form was done by-hand and doesn’t use built-in templates (such as form.as_p).

Can Django’s ModelForms handle something like this?

What is the proper location to handle the data transformation, both when retrieving the model (do I have to make a custom models.Manager?) and when saving it (which save() method do I override? the Model‘s or the ModelForm‘s)?

–UPDATE FOR CLARIFICATION–

In the database:

+-----+---------------------------+-----+
| ... |           owners          | ... |
+-----+---------------------------+-----+
| ... | "a@a.com|b@b.com|c@c.com" | ... |
+-----+---------------------------+-----+

The form:

<form ... >
    ...
    <input type="text" name="owners" />
    <input type="text" name="owners" />
    <input type="text" name="owners" />
    ...
</form>
  • 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-20T20:41:43+00:00Added an answer on May 20, 2026 at 8:41 pm

    You can use forms.MultiValueField and forms.MultiWidget. MultiValueField knows that your model’s one field contains multiple discrete values and the MultiWidget widget knows how each discrete value should be presented. They’ll handle creating unique names for your fields so that they can reconstruct the form from POST values and you won’t have to override any form methods that provide implementation, i.e. you won’t have to override save().

    As you can see, the official docs are a bit thin on the topic. I suggest you take a peek at the code to figure out how everything is wired and what gets called when, since your requirements are always going to need a unique solution, i.e: how many emails will the field contain? Exactly two, so I can specify two CharField widgets by hand, or is it going to be between 0-2, so I have to dynamically construct everything depending on the value passed? If you need a good example as a starting reference, check out this SO question which contains a clean and easy to follow implementation.

    Ideally, you’ll want to have a PipedEmailAddressesField that extends CharField as your model’s field, one that knows that it’s storing piped email addresses. It should be able to construct it’s own appropriate MultiValueField form field which should in turn construct it’s own appropriate MultiWidget field.

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

Sidebar

Related Questions

Given: from django.db import models class Food(models.Model): Food, by name. name = models.CharField(max_length=25) class
Given a class: from django.db import models class Person(models.Model): name = models.CharField(max_length=20) Is it
In Django, given excerpts from an application animals likeso: A animals/models.py with: from django.db
I want to import emails from an mbox format into a Django app. All
Given the code from the Complex Form part III how would you go about
Does anyone know any simple way to retrieve the country from a given IP
is there a way to get the position over sealevel from a given position
Given two interface references obtained from different sources. Is there a programmatic way to
Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
Given: Constructing an ADO Connection object from one thread and giving it to another

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.