diff --git a/django/contrib/admin/views/decorators.py b/django/contrib/admin/views/decorators.py index 4f6662c970..d16fc9ab71 100644 --- a/django/contrib/admin/views/decorators.py +++ b/django/contrib/admin/views/decorators.py @@ -5,7 +5,7 @@ from django.contrib.auth import authenticate, login from django.shortcuts import render_to_response from django.utils.translation import ugettext_lazy, ugettext as _ from django.utils.safestring import mark_safe -import base64, datetime, md5 +import base64, md5 import cPickle as pickle ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. Note that both fields are case-sensitive.") diff --git a/django/contrib/databrowse/plugins/calendars.py b/django/contrib/databrowse/plugins/calendars.py index 5d5a020e6d..a798868b55 100644 --- a/django/contrib/databrowse/plugins/calendars.py +++ b/django/contrib/databrowse/plugins/calendars.py @@ -8,8 +8,6 @@ from django.utils.translation import get_date_formats from django.utils.encoding import force_unicode from django.utils.safestring import mark_safe from django.views.generic import date_based -import datetime -import time class CalendarPlugin(DatabrowsePlugin): def __init__(self, field_names=None): diff --git a/django/contrib/databrowse/plugins/fieldchoices.py b/django/contrib/databrowse/plugins/fieldchoices.py index dea6bac700..0a58e7a6ab 100644 --- a/django/contrib/databrowse/plugins/fieldchoices.py +++ b/django/contrib/databrowse/plugins/fieldchoices.py @@ -7,8 +7,6 @@ from django.utils.text import capfirst from django.utils.encoding import smart_str, force_unicode from django.utils.safestring import mark_safe from django.views.generic import date_based -import datetime -import time import urllib class FieldChoicePlugin(DatabrowsePlugin): diff --git a/django/contrib/databrowse/views.py b/django/contrib/databrowse/views.py index d493f9dad3..c17aad5d85 100644 --- a/django/contrib/databrowse/views.py +++ b/django/contrib/databrowse/views.py @@ -2,8 +2,6 @@ from django.db.models import FieldDoesNotExist, DateTimeField from django.http import Http404 from django.shortcuts import render_to_response from django.contrib.databrowse.datastructures import EasyModel, EasyChoice -import datetime -import time ########### # CHOICES # diff --git a/django/contrib/formtools/preview.py b/django/contrib/formtools/preview.py index bd0ce5cbb7..66583dde95 100644 --- a/django/contrib/formtools/preview.py +++ b/django/contrib/formtools/preview.py @@ -3,7 +3,6 @@ Formtools Preview application. """ from django.conf import settings -from django.core.exceptions import ImproperlyConfigured from django.http import Http404 from django.shortcuts import render_to_response from django.template.context import RequestContext diff --git a/django/contrib/formtools/tests.py b/django/contrib/formtools/tests.py index a5a9222c46..feda6e041e 100644 --- a/django/contrib/formtools/tests.py +++ b/django/contrib/formtools/tests.py @@ -3,8 +3,6 @@ from django.contrib.formtools import preview from django import http from django.conf import settings from django.test import TestCase -from django.test.client import Client - success_string = "Done was called!" test_data = {'field1': u'foo', @@ -88,6 +86,3 @@ class PreviewTests(TestCase): response = self.client.post('/test1/', test_data) self.assertEqual(response.content, success_string) - -if __name__ == '__main__': - unittest.main() diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 4aa5a32e3f..05d322363b 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -2,8 +2,7 @@ from django.utils.translation import ungettext, ugettext as _ from django.utils.encoding import force_unicode from django import template from django.template import defaultfilters -from django.conf import settings -from datetime import date, timedelta +from datetime import date import re register = template.Library() diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py index 7827698e77..b23923b47a 100644 --- a/django/contrib/localflavor/ar/forms.py +++ b/django/contrib/localflavor/ar/forms.py @@ -7,7 +7,6 @@ from django.newforms import ValidationError from django.newforms.fields import RegexField, CharField, Select, EMPTY_VALUES from django.utils.encoding import smart_unicode from django.utils.translation import ugettext -import re class ARProvinceSelect(Select): """ diff --git a/django/contrib/localflavor/generic/forms.py b/django/contrib/localflavor/generic/forms.py index a6d813723c..a5e431e4b3 100644 --- a/django/contrib/localflavor/generic/forms.py +++ b/django/contrib/localflavor/generic/forms.py @@ -1,38 +1,38 @@ -from django import newforms as forms - -DEFAULT_DATE_INPUT_FORMATS = ( - '%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06' - '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' - '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' - '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' - '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' -) - -DEFAULT_DATETIME_INPUT_FORMATS = ( - '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' - '%Y-%m-%d %H:%M', # '2006-10-25 14:30' - '%Y-%m-%d', # '2006-10-25' - '%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59' - '%d/%m/%Y %H:%M', # '25/10/2006 14:30' - '%d/%m/%Y', # '25/10/2006' - '%d/%m/%y %H:%M:%S', # '25/10/06 14:30:59' - '%d/%m/%y %H:%M', # '25/10/06 14:30' - '%d/%m/%y', # '25/10/06' -) - -class DateField(forms.DateField): - """ - A date input field which uses non-US date input formats by default. - """ - def __init__(self, input_formats=None, *args, **kwargs): - input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS - super(DateField, self).__init__(input_formats=input_formats, *args, **kwargs) - -class DateTimeField(forms.DateTimeField): - """ - A date and time input field which uses non-US date and time input formats - by default. - """ - def __init__(self, input_formats=None, *args, **kwargs): - input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS - super(DateTimeField, self).__init__(input_formats=input_formats, *args, **kwargs) +from django import newforms as forms + +DEFAULT_DATE_INPUT_FORMATS = ( + '%Y-%m-%d', '%d/%m/%Y', '%d/%m/%y', # '2006-10-25', '25/10/2006', '25/10/06' + '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006' + '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006' + '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006' + '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006' +) + +DEFAULT_DATETIME_INPUT_FORMATS = ( + '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59' + '%Y-%m-%d %H:%M', # '2006-10-25 14:30' + '%Y-%m-%d', # '2006-10-25' + '%d/%m/%Y %H:%M:%S', # '25/10/2006 14:30:59' + '%d/%m/%Y %H:%M', # '25/10/2006 14:30' + '%d/%m/%Y', # '25/10/2006' + '%d/%m/%y %H:%M:%S', # '25/10/06 14:30:59' + '%d/%m/%y %H:%M', # '25/10/06 14:30' + '%d/%m/%y', # '25/10/06' +) + +class DateField(forms.DateField): + """ + A date input field which uses non-US date input formats by default. + """ + def __init__(self, input_formats=None, *args, **kwargs): + input_formats = input_formats or DEFAULT_DATE_INPUT_FORMATS + super(DateField, self).__init__(input_formats=input_formats, *args, **kwargs) + +class DateTimeField(forms.DateTimeField): + """ + A date and time input field which uses non-US date and time input formats + by default. + """ + def __init__(self, input_formats=None, *args, **kwargs): + input_formats = input_formats or DEFAULT_DATETIME_INPUT_FORMATS + super(DateTimeField, self).__init__(input_formats=input_formats, *args, **kwargs) diff --git a/django/contrib/localflavor/jp/forms.py b/django/contrib/localflavor/jp/forms.py index 13083aab6e..d726f822d7 100644 --- a/django/contrib/localflavor/jp/forms.py +++ b/django/contrib/localflavor/jp/forms.py @@ -7,8 +7,6 @@ from django.newforms import ValidationError from django.utils.translation import ugettext from django.newforms.fields import RegexField, Select -import re - class JPPostalCodeField(RegexField): """ A form field that validates its input is a Japanese postcode. diff --git a/django/contrib/sessions/models.py b/django/contrib/sessions/models.py index dfa7bed226..4769e63b1b 100644 --- a/django/contrib/sessions/models.py +++ b/django/contrib/sessions/models.py @@ -1,10 +1,5 @@ -import os -import sys -import time -import datetime import base64 import md5 -import random import cPickle as pickle from django.db import models diff --git a/django/contrib/webdesign/tests.py b/django/contrib/webdesign/tests.py index da9237a43b..d155620902 100644 --- a/django/contrib/webdesign/tests.py +++ b/django/contrib/webdesign/tests.py @@ -14,7 +14,6 @@ u'lorem ipsum dolor' """ from django.contrib.webdesign.lorem_ipsum import * -import datetime if __name__ == '__main__': import doctest diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index e17b821f52..20797c02f6 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -4,7 +4,6 @@ Serialize data to/from JSON import datetime from django.utils import simplejson -from django.utils.simplejson import decoder from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer try: diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py index 4c32a9686f..58cf59bed9 100644 --- a/django/core/serializers/pyyaml.py +++ b/django/core/serializers/pyyaml.py @@ -4,7 +4,6 @@ YAML serializer. Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__. """ -import datetime from django.db import models from django.core.serializers.python import Serializer as PythonSerializer from django.core.serializers.python import Deserializer as PythonDeserializer diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py index ba3e9efda8..697dcd3a67 100644 --- a/django/db/backends/mysql/base.py +++ b/django/db/backends/mysql/base.py @@ -21,7 +21,6 @@ if (version < (1,2,1) or (version[:3] == (1, 2, 1) and from MySQLdb.converters import conversions from MySQLdb.constants import FIELD_TYPE -import types import re # Raise exceptions for database warnings if DEBUG is on diff --git a/django/test/_doctest.py b/django/test/_doctest.py index d1308b855e..a56483c3ab 100644 --- a/django/test/_doctest.py +++ b/django/test/_doctest.py @@ -100,7 +100,7 @@ __all__ = [ import __future__ -import sys, traceback, inspect, linecache, os, re, types +import sys, traceback, inspect, linecache, os, re import unittest, difflib, pdb, tempfile import warnings from StringIO import StringIO diff --git a/django/test/client.py b/django/test/client.py index b02d298418..67d3aa9030 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -1,7 +1,5 @@ -import datetime import sys from cStringIO import StringIO -from urlparse import urlparse from django.conf import settings from django.contrib.auth import authenticate, login from django.core.handlers.base import BaseHandler diff --git a/django/test/simple.py b/django/test/simple.py index 6fa381ac4d..43e1156a0a 100644 --- a/django/test/simple.py +++ b/django/test/simple.py @@ -146,4 +146,3 @@ def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]): teardown_test_environment() return len(result.failures) + len(result.errors) - \ No newline at end of file