How to use a Django validator to limit dates to 1900 or greater

I found this commit showing the _datere pattern now requires a date > 1900 but ... when I look into django.core.validators today I don't see anything like this (the commit linked to above does say it's from 7 years ago).

What happened to this validation in django and what are people using today in Django 1.4.1 to get this type of validation?

I'm asking this because of the strftime error:

"ValueError('year=1800 is before 1900; the datetime strftime() methods require year >= 1900',)"

Thank you!

Answers


@SimeonVisser gave a great explanation of the reason you used to get this exception and why you no longer do.

If still want dates greater than 1900 as business logic and not as an actual inherent limitation, you should be able to use the built-in Django MinValueValidator. Just feed it a date/datetime of 1900-01-01, i.e.

validators=[MinValueValidator(datetime(1900, 1, 1, 0, 0))]

Need Your Help

How to Apply Corner Radius to LinearLayout

android android-layout

I want to make a layout with a rounded border. How can I apply a radius of a particular size in a LinearLayout?

Powershell Write-EventLog / Get-WinEvent Message issues

powershell powershell-v2.0 powershell-v3.0 event-log powershell-v4.0

The first command creates an entry in the event log, it seems to be working because I can see the message data in event viewer. The issue is when reading it back from powershell the message field...

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.