Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango display content of a manytomanyfield
    text
    copied!<p>I started using django framework just a few days ago and i desperately need some help with my application.</p> <p>It consists of client,project,admin,and admin payment classes where the admin_payment holds the ids of the admins and projects among other stuff.</p> <p>My question is how i can display the "administrator's name" of each "project" in my admin listing of projects? the project class itself does not hold the administrator ids (the Admin_Payment does)</p> <p>Currently i have the following structure: (striped down)</p> <p>models.py</p> <pre><code>class Admin(models.Model): admin_name = models.CharField(unique = True, blank = False, null = False, max_length = 128, verbose_name = u'admin full name') def __unicode__(self): return self.admin_name class Meta: ordering = ('id',) verbose_name = u'Admin Info' class Project(models.Model): client = models.ForeignKey(Client, verbose_name = u'Client') description = models.ForeignKey(Description, verbose_name = u'project description') admins = models.ManyToManyField(Admin, verbose_name = u'Administrators', through = 'Admin_Payment') class Admin_Payment(models.Model): admin = models.ForeignKey(Admin, verbose_name = u'Administrator') project = models.ForeignKey(Project, verbose_name = u'project') </code></pre> <p>admin.py (striped down)</p> <pre><code>class AdminInline(admin.TabularInline): model = Admin class ProjectAdmin(admin.ModelAdmin): radio_fields = {'position': admin.HORIZONTAL, 'solution': admin.HORIZONTAL} inlines = [AdminInline, ] list_display = ['client','description','admin_name'] </code></pre> <p>Clients and Descriptions appear correctly in the project listing but the admin names are not</p> <p>Any help is appreciated (sorry if i posted anything that doesnt make sense , i am a newbie in python and django)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload