Hi, No, year__in should be for a list. For example you can write: Profile.objects.filter(year__in=[2017, 2016, 2015])
so in your case it would be Profile.objects.filter(year=user.birthday.year) You should checkout how selection works in the django documentation: https://docs.djangoproject.com/en/2.0/topics/db/queries/ Regards, Andréas 2018-01-30 0:06 GMT+01:00 Travis Pickle <[email protected]>: > Hiya -- > > Thanks. This is sort of what I was looking for. > > user = User.objects.get(pk=pk) > cars = Car.objects.filter(year=user.birthday.year).all() > UserRelatedProfiles or user_related_profiles = > Profile.objects.filter(year__in=user.birthday.year) ? > > > On Monday, January 29, 2018 at 8:40:13 AM UTC-5, Andréas Kühne wrote: >> >> Hi, >> >> It's really hard to understand what you exactly want. >> >> Without showing your code it'll be even harder to understand how / what >> you want to do. We have to guess from the little information you are >> giving.... However. if you want to query cars with the same year as the >> user for example, you could do this: >> >> user = User.objects.get(pk=1) >> cars = Car.objects.filter(year=user.birthday.year).all() >> > > >> >> Regards, >> >> Andréas >> >> 2018-01-29 14:30 GMT+01:00 Travis Pickle <[email protected]>: >> >>> >>> I'm assuming not a single person has read what is in my body of my >>> message and has only read the subject. I know bots have read the body. >>> >>> if >>> http://somesite.com/user/ <http://somesite.com/user/1>*1 ,where 1 is >>> the pk,* >>> i want to use in the view pk relation to gather all fields, and use >>> fields to generate other query sets to pass to the templates >>> >>> user model has >>> >>> name >>> birthday >>> gender >>> >>> and car model has >>> make >>> model >>> year >>> description >>> and >>> >>> profiles just have a one-to-one relationship to users >>> favorite_car >>> location >>> ..etc >>> >>> so for example, this isn't data isn't what i am working on, but it gets >>> me to where i need to. I want to lookup(get_objects) where cars age is same >>> as user PK 1, and also want to look up other users around same age, and >>> report location. >>> >>> >>> Cant really disclose the code of this project at this time. but just >>> note, I am trying to look for objects based on values from PK1. if I knew >>> how to assign them, and then use it for a search it would have different >>> questions. >>> >>> >>> >>> >>> >>> On Monday, January 29, 2018 at 4:30:03 AM UTC-5, Daniel Roseman wrote: >>> >>>> On Sunday, 28 January 2018 19:01:35 UTC, Travis Pickle wrote: >>>>> >>>>> I am using django 1.8. >>>>> >>>>> I read though the docs, however, i not seeing how I can get the PK >>>>> other attributes to use in model searching. >>>>> >>>> >>>> As others have stated, this is *fully* covered in the tutorial, >>>> specifically in part 3. Potted answer, though: you capture it as a URL >>>> argument and accept it in your view function. If you've read that part of >>>> the tutorial and still can't work it out, you'll need to post some actual >>>> code. >>>> -- >>>> 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 https://groups.google.com/group/django-users. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/django-users/da574efa-cfc8-47fc-8441-a9168e005e15%40googlegroups.com >>> <https://groups.google.com/d/msgid/django-users/da574efa-cfc8-47fc-8441-a9168e005e15%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/a6551d61-72f3-4223-9cad-cdd52a85d405%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/a6551d61-72f3-4223-9cad-cdd52a85d405%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK4qSCc6NEv_Faky8SQEzoqMU5dUBVpiZBZDZF4pOh7WgQq1dw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

