This is something I've been looking around for earlier.  Thanks for
posting it here as well!  I originally found it here: (http://
groups.google.com/group/django-users/browse_thread/thread/
1f97ae29f23f71d4)

But after using that type of method to list a ManyToManyField (in my
case, a field called "authors",) I realized that when viewing a table
that has various column names from the model I was working with (in my
case, a Book model,) I was seeing the name of the function listed in
the column heading.  And that is how it should be with the way I had
it set up initially.

But do you know if there is any way to set a ManyToManyField's column
heading to something besides the function name itself?  For example...
I tried setting verbose_name='authors' in the model... but it didn't
seem to work as expected.  (No error really, it just didn't change the
name of the column heading.)

Have you ever needed to change the column name in a view of a
ManyToManyField?  Anyway... if so, do I need to use something other
than verbose_name?

Thanks for any pointers...
Andy




On Mar 5, 2:55 pm, Kenny Meyer <knny.m...@gmail.com> wrote:
> Wilmer A. Delpratt (wdelprat...@gmail.com) wrote:
>
>
>
>
>
> > Hi everyone..i'm new in this group...my friends says this is one of
> > the best groups...
> > I'd like to know how i can use a ManyToManyField in a "list_display",
> > i've read the documentation, but there says this is not possible
> > (isn't supported),....i wish to know if there is another way to solve
> > this problem (i really need to do that)....well that's all...thanks a
> > lot....
> > PD: Sorry my bad english........i'm from Cuba (official language
> > 'Spanish').
> > Once again thank you all.......please help me.....see you
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> Hey Wilmer :)
>
> First of all I must criticize your attempt to ask a simple question.
> Ever heard of using a meaningful subject [1]_, or how to ask *smart
> questions* [2]_? Your style honestly sucks and is painful to read.=20
> Period.
>
> Back to topic:
> Using a ManyToManyField in the Django's model class is not possible
> AFAIK, but by writing a little Python function you can easily handly
> this.
>
> Take the following example:
>
> class Book(models.Model):
>         ...
>         authors =3D models.ManyToManyField(Author)
>         ...
>
>         def get_authors(self):
>                 return self.authors.all()
>
>         class Admin:
>                 list_display =3D ('get_authors')
>
> This is pretty self-explanatory and not tested, but should work.
>
> > Hi everyone..i'm new in this group...my friends says this is one of
> > the best groups...
>
> They're certainly right your friends. ;)
>
> Hope I could help,
> Kenny
>
> .. [1]http://www.hoax-slayer.com/email-subject-lines.html
> .. [2]http://catb.org/~esr/faqs/smart-questions.html
> --
>   Kenny Meyer
>   Software Geek |http://kenny.alwaysdata.net
>
>   Shoot for the moon, even if you miss, you'll land amongst the stars..
>     - Les Brown

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to