0

I am building a site in the new pbs bento, and am being forced to use django for this instance, which I am not familiar with. Here is what I have:

    {% load sekizai_tags filertags %}
    {% with "%Y-%m-%d %I:%M %p" as the_time %}
    {% if the_time_gteitem01.date %}
    ..............
    {% endif %}
    {% endwith %}  

item01.date is declared elsewhere, and I am for sure that it works fine.

My question is am I doing this right?
I am trying to get the current date and place it in the_time. Then I am checking to see if the_time is greater or equal to item01.date, {% if the_time_gteitem01.date %}. Then I have some html that happens if it is true. Is gte greater than or equal to?
Sorry if I sound like a noob to this, but have never used django or python, and have gotten all my django knowledge from other examples.
Thanks ahead of time.

Jerry YY Rain
  • 4,134
  • 7
  • 35
  • 52

1 Answers1

0

No.

How would the_time become a date? You've declared it as a string.

And what makes you think you do comparisons in templates by appending "gte" and the value to compare? You don't at all.

Assuming that item01.date is an actual date object, you need to pass a variable (called eg today) containing datetime.date.today() from the view, then do a simple comparison:

{% if today > item01.date %}
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Sorry, this is what I was looking at for date https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#assignment-tags, and this was what I was looking at for greater than or equal to http://stackoverflow.com/questions/10040143/how-to-do-a-less-than-or-equal-to-filter-in-django-queryset. Thanks for the answer though! – DragonTorchSlash Jun 29 '14 at 20:01
  • It says, "Could not parse the remainder: '()' from 'datetime.date.today()'" I am using this line of code {% with today=datetime.date.today() %} – DragonTorchSlash Jun 29 '14 at 22:03
  • You can't do that in the template. You need to send the variable from the view. – Daniel Roseman Jun 30 '14 at 06:25
  • I don't have access to the view. Bento doesn't allow us access to access their files in their server at all. Only stuff we upload – DragonTorchSlash Jul 01 '14 at 13:06