Monday, July 6, 2015

Re: Models and relationships

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.

No comments:

Post a Comment