Re: Select Field With Other option

2015-01-28 Thread trubliphone
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

constraining one model's attributes with another's

2012-04-12 Thread trubliphone
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

passing kwargs to forms of a formset - why is this working?

2012-02-09 Thread trubliphone
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(

Re: custom attributes of model field

2011-12-10 Thread trubliphone
} {% 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 '

Re: custom attributes of model field

2011-12-07 Thread trubliphone
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

custom attributes of model field

2011-12-06 Thread trubliphone
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

nested forms?!?

2011-10-25 Thread trubliphone
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

noob struggling with inlineformset_factory

2011-10-11 Thread trubliphone
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