0
I am trying to display some items in manytomany in the list display on Jango, but it is returning an error, follow the codes:
Models py.
class Apenso(models.Model):
usuario = models.ForeignKey(User, blank=True)
processo = models.OneToOneField(Processo, blank=True, default=None)
apensos = models.ManyToManyField(Processo, blank=True, default=None, related_name="Apensos")
def __unicode__(self):
return unicode(self.apenso) or u''
admin py.
class ApensoAdmin(admin.ModelAdmin):
list_display = ('processo', 'get_apensos', 'usuario')
list_display_links = list_display
list_per_page = 30
search_fields = ('processo', 'requerente__nome')
show_change_link = False
def get_apensos(self):
return ", ".join([str(p) for p in self.apenso.all()])
And the error displayed is:
Exception Value:
get_apensos() takes exactly 1 argument (2 given)
Man, basically he is complaining that two arguments were passed to the function "get_apensos()", when in fact he only expects one. Are you sure you’re breaking this part of the code?
– Victor Alessander
I checked here, and there’s only get_attached to that part of the code, there’s nowhere else
– Lucas Junior