Hello, I found a solution for the simplified version of my problem. In models.py, I use:
def __unicode__(self): oses_installed = u','.join(self.operatingsystemused.all().values_list('operatingsystem', flat=True)) return ("%s" % (oses_installed)) However, it doesn't works in admin.py Following lines give me (None): def renvoi_os(maintenance): oses_installed = u','.join(maintenance.ordi.operationsystemused_set.all().values_list('operatingsystem',flat=True)) return ("%s" % (oses_installed)) class MaintenanceAdmin(admin.ModelAdmin): list_display = (renvoi_os,) Thanks for your help On 2 fév, 03:31, Rainy <andrei....@gmail.com> wrote: > On Feb 1, 6:12 pm, makayabou <makaya...@gmail.com> wrote: > > > > > Hello, > > I try to simplify the problem. > > > This model gives me a (None) result: > > > class OperatingSystem (models.Model): > > operatingsystem = CharField (max_length=30, blank=True, null=True) > > def __unicode__(self): > > return "%s" % (self.operatingsystem) > > class Ordi(models.Model): > > architecture = CharField (max_length=30, blank=True, null=True) > > operatingsystemused = ManyToManyField(OperatingSystem, null=True, > > blank=True) > > > def __unicode__(self): > > oses_installed = > > u','.join(self.operationsystemused_set.all().values('operatingsystem',flat= > > True)) > > return ("%s" % (oses_installed)).upper() > > > Or also the same with that last line: > > > return models.join(list(self.operatingsystemused)) > > > What can I do?? > > > thanks > > How about > self.operatingsystemused.all().values('operatingsystem',flat= True) > > -ak -- 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.