You must add a ManyToManyField in your models
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField
class Person(models.Model):
name = models.Charfield(max_lenght=200)
colours = models.ManyToManyField(Color)
class Color(models.Model):
name = models.Charfield(max_lenght=200)
persons = models.ManyToManyField(Person)
and in your admin.py, you must redefine your ModelForm and remplace it in ModelAdmin : http://stackoverflow.com/questions/1226760/filter-manytomany-box-in-django-admin
BILLION Sébastien
the Answer to the ultimate question of life, the universe and everything is42
http://www.sebastienbillion.com/
the Answer to the ultimate question of life, the universe and everything is
http://www.sebastienbillion.com/
Le 30/09/2011 02:55, bino oetomo a écrit :
Dear All ..
Let's say I have 2 model in manyTOmany relation, i.e : Persons and colours
I want a 2 CRUD interface for this , that is :
1. Persons : where I can add colours to each person, and
2. Colours : where I can add Persons to each colour
I also want the "ADD" methode (Add colours to person, and add Persons to colour) is just like the Django "User Admin" interface .. when we want to asign user-rights to a user.
Just for reference I post the screen capture of it at http://i55.tinypic.com/33l2umg.png
How to do that ?
Will I need an intermediate model (i.e : PersonColour) ?
Kindly please give me your enlightment.
Sincerely
-bino-
No comments:
Post a Comment