Friday, November 30, 2018

Re: objects.filter

Hi todor, 

Thanks very much you save my day... 

Regards

On Sat, 1 Dec 2018, 12:18 Todor Velichkov, <todorvelichkov89@gmail.com> wrote:
It would be

logbook_noc.objects.filter(StatusProgress__in = ['1 Pending', '2 On Progress'])

You can read more about this at Making queries and please take a look at Coding styles and PEP8, because reading this code is a pain.

On Friday, November 30, 2018 at 8:28:22 AM UTC+2, pujiarahman wrote:
helo, 
iam new for python.  

my : models.py

lass logbook_noc(models.Model):
idLogbookN = models.IntegerField(primary_key=True)
kodetiket = models.CharField(max_length=30)
CustName = models.CharField(max_length=30)
TanggalLo = models.DateTimeField()
DeskripsiLo = models.TextField()
StatusProgress = models.CharField(max_length=30)
PenangananLo = models.TextField()
TglUpdate = models.DateTimeField()


class Meta:
managed = False
db_table = 'logbook_noc'
def __str__(self):
return self.Id

  
 my: views.py

def home(request):
logbooks = logbook_noc.objects.filter(StatusProgress = '1 Pending' )
paginator = Paginator(logbooks, 8)
page = request.GET.get('page')
pb = paginator.get_page(page)
return render(request, 'blog/home.html', {'pb':pb})


how to add  one word again to filter like '2 On Progress'
i tray to logbooks = logbook_noc.objects.filter(StatusProgress = '1 Pending' or '2 On Progress' )
the output for status is only 1 Pending the 2 On Progress not display..

Thanks

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3f69d7a1-e522-450c-99f6-62506652b3d2%40googlegroups.com.
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+unsubscribe@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/CABbNnG6nHf1veh_kzmZCR6i18v_ugxdpaHaEwFwSps%2B79%3D-8Ng%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment