Discussion:
objects.filter
pujiarahman
2018-11-30 06:28:21 UTC
Permalink
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+***@googlegroups.com.
To post to this group, send email to django-***@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/6cdf4e2b-86a6-4db9-a39a-6dac4015a911%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Todor Velichkov
2018-12-01 05:17:49 UTC
Permalink
It would be

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

You can read more about this at Making queries
<https://docs.djangoproject.com/en/2.1/topics/db/queries/> and please take
a look at Coding styles
<https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/>
and PEP8 <https://www.python.org/dev/peps/pep-0008/>, because reading this
code is a pain.
Post by pujiarahman
helo,
iam new for python.
my : models.py
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()
managed = False
db_table = 'logbook_noc'
return self.Id
my: views.py
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+***@googlegroups.com.
To post to this group, send email to django-***@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.
Aqilah Maulidya Sidik
2018-12-01 05:47:36 UTC
Permalink
Hi todor,

Thanks very much you save my day...

Regards
Post by Todor Velichkov
It would be
logbook_noc.objects.filter(StatusProgress__in = ['1 Pending', '2 On
Progress'])
You can read more about this at Making queries
<https://docs.djangoproject.com/en/2.1/topics/db/queries/> and please
take a look at Coding styles
<https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/>
and PEP8 <https://www.python.org/dev/peps/pep-0008/>, because reading
this code is a pain.
Post by pujiarahman
helo,
iam new for python.
my : models.py
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()
managed = False
db_table = 'logbook_noc'
return self.Id
my: views.py
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
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
<https://groups.google.com/d/msgid/django-users/3f69d7a1-e522-450c-99f6-62506652b3d2%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+***@googlegroups.com.
To post to this group, send email to django-***@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.
Continue reading on narkive:
Loading...