Hi all,
in a many-to-many relationship, I would like to use a custom to_field,
like in this intermediate model definition:
class MitarbeiterBereiche(models.Model):
mitarbeiter = models.ForeignKey(Mitarbeiter, to_field='key')
bereich = models.ForeignKey(Bereich)
class Meta:
db_table = u'Mitarbeiter_Bereiche'
The intention with this table is to exactly mimic the default
intermediate table that Django would create when the keyword "through"
is not used in the ManyToManyField statement (manually adding the
UNIQUE(...) database constraint), with just the "to_field" not at 'id'
but at 'key'.
The problem with the above approach is that (as documented at
<http://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manytomany>),
even though no extra data is used, I then
- cannot use the add, create, or assignment (i.e., beatles.members =
[...]) to create relationships, and
- the ManyToManyField cannot be shown with filter_horizontal in the
admin pages.
(The latter is the "real" problem.)
Is there a way to have a custom to_field in an intermediate table
without sacrificing the filter_horizontal feature in the admin?
Thank you very much, and best regards,
Carsten
--
Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
Learn more at http://www.cafu.de
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.