Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
ManyToMany through parameter bug workaround.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Nicolas Emiliani  
View profile   Translate to Translated (View Original)
 More options Aug 18 2012, 12:30 pm
From: Nicolas Emiliani <or3s...@gmail.com>
Date: Sat, 18 Aug 2012 13:30:06 -0300
Local: Sat, Aug 18 2012 12:30 pm
Subject: 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 :

https://groups.google.com/forum/?fromgroups#!topic/django-users/nWpb0...

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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Emiliani  
View profile  
 More options Aug 18 2012, 4:17 pm
From: Nicolas Emiliani <or3s...@gmail.com>
Date: Sat, 18 Aug 2012 17:17:07 -0300
Local: Sat, Aug 18 2012 4:17 pm
Subject: Re: ManyToMany through parameter bug workaround.

> 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.

Well, I kept on reading and I found a clean solution :

It's explained here, the same happened to this guy and a workaround is
provided.
The code in  MHCs response example has a few errors, but the idea is pretty
clear.

http://stackoverflow.com/questions/2854350/django-admin-many-to-many-...

Hope it saves some headaches.

> --
> 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »