Tuesday, June 26, 2012

Re: How to Query objects.filter ForeignKey

 I performed infobox = InfoDetail.objects.filter(title=info_title), but it returns an error cus 'title' doesn't live in InfoDetail.

How can i grab and filter it by title and pass {'infobox': infobox} in HttpResponse when HttpRequest is called?

If you want to filter by a certain title, then you'd do something like this:

InfoDetail.objects.filter(infobox__title="Some Title") 

That would return all InfoDetail objects whose related InfoBox has a specific title.

If that doesn't help solve your problem, let me know what else you're stuck on :)

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment