Hello Fernando, Just as a quick example, you could do something like this:
class Factory(models.Model): # Assuming suppliers and customers are just two sides of the same relationship suppliers = models.ManyToManyField("self", related_name="customers") Then simply query accordingly: factory_a = Factory.objects.create() factory_b = Factory.objects.create() factory_c = Factory.objects.create() factory_b.customers.add(factory_a) factory_c.suppliers.add(factory_a) Documentation: https://docs.djangoproject.com/en/dev/ref/models/fields/#manytomanyfield https://docs.djangoproject.com/en/dev/topics/db/queries/#many-to-many-relationships https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_many/ On Thu, Aug 23, 2012 at 8:20 AM, Fernando Andreacci <fandrea...@gmail.com>wrote: > Hello, > > I'm a new Django user, and I have the following question: > > I have one Model called *factory, *with several fields like (name, > address, phone, etc). > > Each factory can be a customer, a supplier or both. > > Ex: > Factory1 is a customer of Factory2, and Factory1 is a supplier of Factory3. > > How can I set up the models to hold this information? > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/C0KQX7HoCTUJ. > 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. > -- 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.