Monday, July 6, 2015

Re: Models and relationships

WOO HOO !.. success ... thanks everyone...
 just needed a nudge in the right direction .... I will tackle the templates tomorrow and see where that takes me.

On Mon, Jul 6, 2015 at 2:24 PM, Rafael E. Ferrero <rafael.ferrero@gmail.com> wrote:
contacts = Contacts.objects.select_related()

--
Rafael E. Ferrero

2015-07-06 13:51 GMT-03:00 Florian Schweikert <kelvan@ist-total.org>:
On 06/07/15 14:04, Chris Strasser wrote:
> my problem is with reverse lookups (i think it is called) the docs say that i can access entries through blog.entry,(by lowercaseing the class)
> it appears to me that i have the same setup with contact and location but i am getting errors ??

I think you forgot about "_set".
Try something like:

Location.contact_set.all()

And please don't use AutoField, db_column and primary_key until you have
a good reason. Also ForeignKey fetches an object of the connected type,
not an id, so "contactid", ... is confusing ;)

--
Florian

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/559AB201.40600%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/YYM-cTEZOgA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAJJc_8Vn72yWdFwUEFXRXD_4yOhD%2Bzx7n%3D0T189AsfGFU1n7Yg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAH3cd3qiW0vKX_TxpmjuY5ZfVaVG2BPM1DK%2Byjt8Raw7-PrU0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment