django filter

18 views
Skip to first unread message

sum abiut

unread,
Aug 28, 2017, 7:07:18 PM8/28/17
to django...@googlegroups.com
Hi all,
i am working on an eleave system where staff apply for annual leave and their leave manager approved the leave online.

currently i have a table that shows all the leave for each department. what i want to accomplished is to only show the leave that are not yet approved on the table. Any leave that have been approved should not be showing on the table.

Please point me to the right direction.


Cheers

Muhammad M

unread,
Aug 28, 2017, 7:14:19 PM8/28/17
to django...@googlegroups.com
Hi Sum,

Add an "approved" field of type BooleanField ( ) to your Leave model. 

So, something like this should work: 

In app/models.py:

class Leave (models.Model):
    #other fields go here...
    approved = models.BooleanField ( )

In app/views.py, handle the query like this:
     unapproved_leaves = Leave.objects.filter (approved=False)

Then, do with the returned queryset as you wish. 

Best of luck.

Sincerely,
Muhammad 

--
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...@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/CAPCf-y6f6%3DWtOW%3DQNW%3DD59gWtAmc3avZ4s3jHA09Pgj6C4yXEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

sum abiut

unread,
Aug 28, 2017, 11:45:50 PM8/28/17
to django...@googlegroups.com
Thanks heaps Muhammad.
Sum


For more options, visit https://groups.google.com/d/optout.



-- 

sum abiut

unread,
Aug 29, 2017, 2:00:37 AM8/29/17
to django...@googlegroups.com
I did that but the approved leave is still showing on the table.

Cheers
-- 

Muhammad M

unread,
Aug 29, 2017, 4:21:18 AM8/29/17
to django...@googlegroups.com
Please, post your related code (from your models, views and template) here so that we can take a look.

Thank you.


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.
Reply all
Reply to author
Forward
0 new messages