django filter

已查看 18 次
跳至第一个未读帖子

sum abiut

未读,
2017年8月28日 19:07:182017/8/28
收件人 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

未读,
2017年8月28日 19:14:192017/8/28
收件人 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

未读,
2017年8月28日 23:45:502017/8/28
收件人 django...@googlegroups.com
Thanks heaps Muhammad.
Sum


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



-- 

sum abiut

未读,
2017年8月29日 02:00:372017/8/29
收件人 django...@googlegroups.com
I did that but the approved leave is still showing on the table.

Cheers
-- 

Muhammad M

未读,
2017年8月29日 04:21:182017/8/29
收件人 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.
回复全部
回复作者
转发
0 个新帖子