$(document).ready(function(){ var v = '{{ A }}'; if (v) $('#A option[value*="'+v+'"]').attr('selected', 'selected'); $('#A').change(function(){ var t = $("#A option:selected").val(); window.location.href = '{% url url %}'+'?limit_time='+t; }); }); <select id='A' name="A"> <option value="">所有</option> <option value="">近三個月</option> <option value="">三個月前</option> </select> from datetime import date, timedelta limit_time = request.GET.get('A') if limit_time: now = date.today() t = now + timedelta(days=-90) if limit_time == u'':