This might be a simple question, but i can't seem to grasp it.
I have two simple models in models.py: Service and Host. Host.services has a m2m relationship with Service.
In other words, a host has several services and one service can reside on multiple hosts; a basic m2m.
servicename = models.CharField(max_length=50)
hostname = models.CharField(max_length=200)
services = models.ManyToManyField(Service)
from cmdb.hosts.models import Host
from django.contrib import admin
list_display = ('get_services',)
[<Service: the_service-1>, <Service: the_service-2>]
You should change
get_services to something like:
def get_services(self): return "\n".join([s.servicename for s in self.services.all()])
Update: Try using
\n as the separator rather than
<br/>, as the output of get_services is being escaped.