masterofdestiny
masterofdestiny

Reputation: 2811

Django: Two or more filters in django queryset

I want to apply two filters in my django queryset

i am trying to do like

 get.archived:get_meetings = Meeting.objects.filter(created_by = user_id.id).filter(date_created__lte = datetime.date.today()[index:limit]

but i am getting the syntax error .

I also tried Q but here i couldn't find the and like statement or is there please help me how can i acheive this in django

Upvotes: 0

Views: 295

Answers (2)

Qiang Jin
Qiang Jin

Reputation: 4467

Just put the two filters together,

get_meetings = Meeting.objects.filter(created_by = user_id.id, date_created__lte = datetime.date.today())[index:limit]

Upvotes: 2

Aamir Rind
Aamir Rind

Reputation: 39659

you are missing closing parenthesis ) at the end after datetime.date.today(), this should work.

get_meetings = Meeting.objects.filter(created_by = user_id.id).filter(date_created__lte = datetime.date.today())[index:limit]

Upvotes: 3

Related Questions