On Monday, 30 March 2015 13:04:00 UTC+1, François GUÉRIN wrote:
>
> Hi all, 
>
> I'm using django for a couple of years, and I've a question about 
> relations in the ORM and templates. I massively use class-based generic 
> views.
>
> I' currently working with a model which have many other models FKing to it 
> : 
>
>
> class People(models.Model):
>     last_name = models.CharField(max_length=255)
>     ... other fields ...
>
> class PhoneNumber(models.Model):
>     people = models.ForeignKey("my_app.People")
>     number = models.CharField(max_length=255)
>     ... other fields ...
>
> According to documentation, it is possible to use a `People.phonenumber
> _set` attribute from a people instance, queryset'ing related phone 
> numbers from people.
>
> in may template "myapp/people_detail.html", when I query this attribute 
> from my template, by using {% for phonenumber in object.phonenumber
> _set.all %}[% endfor %}, I do not any phone number... 
>
> When I step -to-step debug the application, I can see a 
> "myapp_phonenumber_related" related manager, but no phonenumber_set.
>
> Do I miss something ?
>
> Thanks for your great job...
>
>
>
You don't seem to be giving all the information here. If you have a  
`myapp_phonenumber_related` 
manager, that can only be because you've set that explicitly as the 
`related_name` attribute of the ForeignKey. And having done so, that's what 
you should be using in place of `phonenumber_set` anyway.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7ccde7fb-c98d-4a54-808e-2c72a37f4279%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to