Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
Created October 14, 2011 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sindresorhus/1286924 to your computer and use it in GitHub Desktop.
Save sindresorhus/1286924 to your computer and use it in GitHub Desktop.
Django - If you have 2 date-pickers in the admin form, one for start date and one for end date, this will make sure the second picker is the same month as the first. Which improves the usability of the picker.
{% extends "admin/change_form.html" %}
{% block extrahead %}
{{ block.super }}
<script >
// override openCalendar to set the date of calendar A to calendar B
var _openCalendar = DateTimeShortcuts.openCalendar;
DateTimeShortcuts.openCalendar = function(num) {
_openCalendar.call( this, num );
var cals = DateTimeShortcuts.calendars;
cals[1].drawDate( cals[0].currentMonth, cals[0].currentYear );
};
</script>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment