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 ModelForm
s 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>