Django working with date

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.

Answers


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 %}

Need Your Help

I want To take registration Fee in Opencart

opencart

I am developing e-commerce website using opencart framework , now i want to take registration fee $25 while registering user , so how i can implement it or any one have extension for that. please h...

Curious type error in java generics

java generics

I've encountered a strange issue with the following code (well, not exactly this code):

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.