ManyToMany through parameter bug workaround.
Hi,
I was trying to create an m2m relationship using the 'through' parameter because
I want to have an additional field in the relation table. The idea was to render this
using CheckboxSelectMultiple.
The thing is that when I add the model m2m field to the 'fieldset' field at the
ModelForm it throws an exception :
'HomeAdmin.fieldsets[4][1]['fields']' can't include the ManyToManyField field 'attributes' because 'attributes' manually specifies a 'through' model.
Apparently this is a BUG pointed out here :
Basically if you use the 'through' parameter to use a relation table that contains an extra field/s
you can't render it using a CheckboxSelectMultple widget, not even if the extra field allows null
values.
I thought of fixing it this way (a nasty hack) :
class A(models.Model):
.
.
foos = models.ManyToManyField('Foo')
class Foo(models.Model):
name = CharField
And here comes the nasssty
class FooRelationshipValue(models.Model):
a = ForeingKey(A)
foo = ForeingKey(Foo)
value = DateField
Here I can store the value for the relationship when saving the Model in the DB.
If anyone has a better solution, suggestion, comment or thinks this is going
to make me rot in hell please let me know.
Thanks.
--
Nicolas Emiliani
Lo unico instantaneo en la vida es el cafe, y es bien feo.
-- Nicolas Emiliani
Lo unico instantaneo en la vida es el cafe, y es bien feo.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home