goabbear | 31 Jul 2012 11:33
Picon

presenting a manytomany relationship in a tabular way

Hi all,

I start with django but after some searches I can't do what I want in the admin section of my app.
There's 3 tables, user(name, mail), mailinglist(name) and an intermediate table subscription where are stored all the users joining some mailinglists. 
How can I present the "subscription" table to the admins like a spreadsheet, where the first column represents the users emails and one other column is a mailinglist name. On each row, the admin can activate the subscription for each user by checking a checkbox?
thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/OJSABe8rdWUJ.
To post to this group, send email to django-users <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Melvyn Sopacua | 31 Jul 2012 15:44
Picon
Gravatar

Re: presenting a manytomany relationship in a tabular way

On 31-7-2012 11:33, goabbear wrote:

> There's 3 tables, user(name, mail), mailinglist(name) and an intermediate 
> table subscription where are stored all the users joining some 
> mailinglists. 
> How can I present the "subscription" table to the admins like a 
> spreadsheet, where the first column represents the users emails and one 
> other column is a mailinglist name. On each row, the admin can activate the 
> subscription for each user by checking a checkbox?

You need a combination of list_display and modeladmin actions:
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display>
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/>

Alternatively, you can use list_editable:
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable>

-- 
Melvyn Sopacua

--

-- 
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 <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

goabbear | 3 Aug 2012 15:07
Picon

Re: presenting a manytomany relationship in a tabular way

Hi,

thanks for the links, I have look at these docs but I can't figure out how to mix actions with a spreadsheet like presentation :-/
Is it possible to create admin forms like we can standards forms?
Another way I could try is to use filter_horizontal (I like this presentation), but for a m2m relation, just 1 entity can be presented with this widget, not the other side, or I do something wrong?

Le mardi 31 juillet 2012 15:44:51 UTC+2, Melvyn Sopacua a écrit :
On 31-7-2012 11:33, goabbear wrote:

> There's 3 tables, user(name, mail), mailinglist(name) and an intermediate
> table subscription where are stored all the users joining some
> mailinglists.
> How can I present the "subscription" table to the admins like a
> spreadsheet, where the first column represents the users emails and one
> other column is a mailinglist name. On each row, the admin can activate the
> subscription for each user by checking a checkbox?

You need a combination of list_display and modeladmin actions:
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_display>
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/>

Alternatively, you can use list_editable:
<https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_editable>

--
Melvyn Sopacua

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/FH-4odtqbSMJ.
To post to this group, send email to django-users <at> googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Gmane