Jump weekends function? Django/python
<p>I need to jump Saturday and Sunday automatically everyday so I can do a count in of certain element from a model. This is an example of the table I need to create:</p>

<pre class="lang-none prettyprint-override"><code>Date ------- Order Holds

Today ------ 45 (wednesday)

09/09/16 --- 34 (Thursday)

10/09/16 --- 23 (Friday)

-----JUMP WEEKEND --- (and keep count in)

13/09/16 --- 56 (Monday)

14/09/16 --- 14 (Tuesday)
</code></pre>

<p>This is how I filter to count the number of holds for today, and I can keep getting them by adding 1 day:</p>

<p>This is my model(models.py):</p>

<pre><code>class Data(models.Model):
    date = models.DateField(null=True, blank=True)
    ban = models.CharField(max_length=10)
</code></pre>

<p>This is part of my logic (views.py)</p>

<pre><code>today = datetime.today()
tomorrow = today + timedelta(days=1)
orders = Data.objects.filter(date=today)
ban = orders.filter(ban__contains="BAN").count()
</code></pre>

<p>As you can see in my views.py logic I can filter all the BAN status from today's date, after that I can count them with now issue. My problem is that I if I filter for tomorrow and tomorrow is Friday I need to jump Saturday and Sunday. In other words, apply that logic everyday by just jumping weekends.</p>

<p>Look into the date.weekday() function. It is an instance method of the <code>date</code> and <code>datetime</code> classes in Python. It returns the day of the week as in integer, with Monday as 0 and Sunday as 6. So you would want to skip days with <code>date.weekday() &gt;= 5</code></p>

<p>See more here: <a href="https://docs.python.org/2/library/datetime.html" rel="nofollow">https://docs.python.org/2/library/datetime.html</a></p>

python dayofweek weekday