Hi Piotr,
The problem is with your custom managers. You defined PersonPhones
manager (and all your other managers) to do nothing and hooked it to
objects effectively confusing everything.
Ideaally you should have:
objects = models.Manager()

But in your case its:
objects = PersonPhonesManager()

By doing that, when you call .objects.all() python runs
PersonPhonesManager() as you specified in your code instead of the
default models.Manager()

If you want the behavior of the default objects.all() then change the
line where you have objects = PersonPhonesManager to models.Manager()
or else you will have to specify what exactly you want
PersonPhonesManager to do instead of the pass statement you put in
your code. You can check the documentation on custom managers for more
information and let me know if you still need assistance

On 10/15/11, Piotr Hosowicz <[email protected]> wrote:
> Hello,
>
> I still do not understand how things are connected in Django. In
> models.py I have:
>
> class CampaignManager(models.Manager):
>     pass
>
> class CampPeople(models.Model):
>     person = models.ForeignKey(Person)
>     camp = models.ForeignKey(Campaign)
>     docall = models.BooleanField(True)
>     called = models.BooleanField(False)
>     objects = CampaignManager()
>
> class Phone(models.Model):
>     # person = models.ForeignKey(Person)
>     phone = models.CharField(u"Telefon", max_length=255)
>     def __unicode__(self):
>         return "%s" % (unicode(self.phone) or "")
>
> class PersonPhonesManager(models.Manager):
>     pass
>
> class PersonPhones(models.Model):
>     person = models.ForeignKey(Person)
>     phone = models.ForeignKey(Phone)
>     objects = PersonPhonesManager()
>     def __unicode__(self):
>         return "%s" % (unicode(self.phone) or "")
>
> In the template I have:
>
> <table>
>
> {% for piplok in camppeople %}
> {% if piplok.docall %}
>   <tr>
>   <td>{{ piplok.person.label }}
>   </td>
>   <td>
>   {{ personphones.phone }}
>   </td>
>   </tr>
> {% else %}
>   NOT
> {% endif %}
> {% endfor %}
>
> </table>
>
> And I do not see any  row output.
>
> Please help,
>
> Regards,
>
> Piotr Hosowicz
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to