hi all,

i have a (probably quite simple) problem concerning the use of
intermediary tables.
i am trying to create a list of users.
users are members of different groups and within these groups they can
have several positions/status (e.g. management, staff member, e.g.).

my models look like this:

class Department
member = ManyToManyField('User', through='Membership',
blank=True,null=True)
...
class User
...

class Membership
StatusChoices = (
    ('m','Management'),
    ('s','Staff'),
user = ForeignKey('User')
department = ForeignKey('Department')
status = CharField(max_length=1,choices=StatusChoices)

what i am trying to achieve is a template that displays the following
information:

Department A
   Management
      User1
   Staff
      User2
      User3

Department B
   Management
      User4
   Staff
      User5
      User6

so i created a view which sends the group information to a template:
deps = Department.objects.all().select_related().order_by('name')
return object_list(request, queryset=deps...)

it's pretty easy to get the members for each group in the template
    {% for m in object.member.all %}
    {{ m.surname }}
    {% endfor %}

i even manage to access the status of a user
 {% for m in object.depmembership_set.select_related %}
    {{ m.status }}
 {% endfor %}

but somehow i don't get the pieces together, say, getting a view that
groups the users by their status (as sketched above) and displays all
the users detail  information (phone,email).

i wondering if i just miss some basic understanding of the way
django's templates work (accessing intermediary tables/related data)
or if the problem is more basic:
maybe i am sending insufficient data to the template (adding more data
via the context?)

any clues and hints are greatly appreciated.

andreas




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to