Although it of course can't hurt to memorize the political affiliation of each president, it's not entirely necessary--mostly because the nature of political parties themselves have changed so much since America's founding (for instance the Republican Party today is far different than the Republican Party during Lincoln's time). It would be more useful to understand how and why these political parties shifted so much.