Perplexing many-to-many problem
===============================

When attempting to iterate a many-to-many relationship of a context
variable, I am receiving a weird template error.
Any help would be greatly appreciated!


My Models
---------

Person()
  projects = models.ManyToManyField(Task, blank=True)

Task()


Middleware
----------

- custom middleware which is inserting person into request (very
similar to contrib.auth)
- request context processor which puts request into my template


What Works as Expected
----------------------

{{ request.person.name }} works fine

{{ request.person.company.name }} (where company is a FK) works fine

{{ request.person.projects }} returns
<django.db.models.fields.related.ManyRelatedManager object at
0x01564B10>

{% for project in request.person.notaproperty %} skips the for loop as
expected

{% for project in request.person.projects %} returns an "iteration over
non-sequence" as expected (a ManyRelatedManager isn't iterable, the
.all() queryset is)

What Doesn't (aka, The Problem)
-------------------------------

{% for project in request.person.projects.all %}

It returns a template error. Here are the final lines of the traceback:

 File "D:\Web\Python24\lib\site-packages\django\db\models\query.py" in
parse_lookup
  734. joins2, where2, params2 = lookup_inner(path, lookup_type, value,
opts, opts.db_table, None)
File "D:\Web\Python24\lib\site-packages\django\db\models\query.py" in
lookup_inner
  835. raise TypeError, "Cannot resolve keyword '%s' into field" % name

  TypeError at /projects/
  Cannot resolve keyword 'person' into field


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to