I have done something fairly similar.
I wound up using two separate fields (rather than a single
MultiValueField). The first one is based on a TextField and its formfield
is based on a MultipleChoiceField. On form creation of forms that use this
field, I append [("_OTHER", "---OTHER---")] to
All,
I am at my wit's end trying to come up with a structure to do the
following. I have a "MasterModel" that acts as a template for an
"InstanceModel." The MasterModel defines a set of name/value pairs.
Each InstanceModel must have a name that corresponds to one of the
names of the MasterModel
All,
I have managed to get some code working that passes extra kwargs to the
__init__() function of the member forms of a formset. This is good.
But I have no idea why it works. Here is my basic code:
class MyModel(models.Model):
myField = models.CharField(max_length=10)
class MyForm(
}
{% if field.name in fieldsOfType %}
{{ field }}
{% endif %}
{% endfor %}
{% endwith %}
{% endfor %}
And this, finally, works. It sticks fields 'a', 'b', and 'c' into a
div with id="ONE" and field '
Thanks very much for this.
This looks very promising. And I know that it may seem inappropriate
to mix presentation logic with application logic, but I plan on doing
other things on the model based on these field types. So your second
example should fit well.
On Dec 7, 1:22 am, Doug Ballance w
Hello,
Is there a way in Django to add custom attributes to a model fields
(without resorting to subclassing fields)?
I would like to only display certain fields in certain sections of my
template. (Eventually, each type of field will be displayed in a
separate tab.) I thought about adding
I am just banging my head against the wall and making no progress with
this issue.
I am trying to create a view that nests forms of related models. I had
thought that inlineformset_factory would do the trick, but I clearly
don't understand something.
Assume I have the following models:
cl
Hello,
I am new to Python and Django and struggling with the concept of
inlineformset_factories.
I am trying to have a view that nests one form inside another. Consider
these models:
class PersonModel(models.Model):
name = models.CharField(max_length=255)
job = models.ForeignKey(Jo
8 matches
Mail list logo