OR
from django.db.models import Q
news_list =
LeagueNews.objects.filter(Q(publication_date__lte=timezone.now)|Q(league_name='english')).order_by('-publication_date')[:10]

AND
news_list = LeagueNews.objects.filter(publication_date__lte=timezone.now,
league_name='english').order_by('-publication_date')[:10]

On Sun, 17 Mar, 2019, 7:25 PM omar ahmed, <omarkad...@gmail.com> wrote:

> hi guys
> this is my view
> def premierleague(request):
> news_list =
> LeagueNews.objects.filter((publication_date__lte=timezone.now)|(league_name='english')).order_by('-publication_date')[:10]
> return render(request, 'core/premierleague.html', {'news_list':news_list})
> i want to filter my objects by two columns
> publication_date and league_name
> but it doesn't work
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/58a97b33-b41e-4f87-a003-e9f82bcb9790%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/58a97b33-b41e-4f87-a003-e9f82bcb9790%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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAD-d1sbsWA5q_M2SQdTfVpePHm3vkyXdvdko2imNZfrtwFg_vA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to