Austin here is an object from the model of one of my applications. The
self referential many-to-many relationship is optional and works find
in the admin interface. Note that you may or may not need the
symmetrical part.
class Customer(models.Model):
"""
A Customer is anyone we have sold to or to whom we would like to
sell.
It can also be someone related to the process of selling, like a
Dealer.
Customers can be associated with other Customers. For example, a
School
may be associated with a District and a Region and a Dealer and a
Co-op.
"""
name = models.CharField(maxlength=200)
customer_type=models.ForeignKey(CustomerType)
associated_with =
models.ManyToManyField("self",null=True,blank=True,symmetrical=False)
notes = models.TextField(blank=True,default="")
def __str__(self):
return self.name
class Admin:
list_display=('name','customer_type')
search_fields= ['name',]
list_filter=['customer_type']
--gordy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---