diff --git django/bin/__init__.py django/bin/__init__.py
new file mode 100644
index 0000000..675001b
--- /dev/null
+++ django/bin/__init__.py
@@ -0,0 +1 @@
+# Extra file is required to keep py2exe happy
\ No newline at end of file
diff --git django/conf/project_template/__init__.py django/conf/project_template/__init__.py
new file mode 100644
index 0000000..05cb70d
--- /dev/null
+++ django/conf/project_template/__init__.py
@@ -0,0 +1 @@
+# Extra file is required to keep py2exe happy
     def base_url_parameters(self):
diff --git django/core/management/__init__.py django/core/management/__init__.py
index 5b0ad6c..62f0796 100644
--- django/core/management/__init__.py
+++ django/core/management/__init__.py
@@ -3,11 +3,14 @@ import os
 import sys
 from optparse import OptionParser, NO_DEFAULT
 import imp
+import warnings
+from pkgutil import iter_modules
 
 from django.core.exceptions import ImproperlyConfigured
 from django.core.management.base import BaseCommand, CommandError, handle_default_options
 from django.core.management.color import color_style
 from django.utils.importlib import import_module
+from django.utils._os import upath
 from django.utils import six
 
 # For backwards compatibility: get_version() used to be in this module.
@@ -17,54 +20,18 @@ from django import get_version
 # doesn't have to reload every time it's called.
 _commands = None
 
-def find_commands(management_dir):
+def find_commands(app_name):
     """
-    Given a path to a management directory, returns a list of all the command
-    names that are available.
+    Given an application name, returns a list of all the commands found.
 
-    Returns an empty list if no commands are defined.
+    Raises ImportError if no commands are defined.
     """
-    command_dir = os.path.join(management_dir, 'commands')
-    try:
-        return [f[:-3] for f in os.listdir(command_dir)
-                if not f.startswith('_') and f.endswith('.py')]
-    except OSError:
-        return []
-
-def find_management_module(app_name):
-    """
-    Determines the path to the management module for the given app_name,
-    without actually importing the application or the management module.
-
-    Raises ImportError if the management module cannot be found for any reason.
-    """
-    parts = app_name.split('.')
-    parts.append('management')
-    parts.reverse()
-    part = parts.pop()
-    path = None
-
-    # When using manage.py, the project module is added to the path,
-    # loaded, then removed from the path. This means that
-    # testproject.testapp.models can be loaded in future, even if
-    # testproject isn't in the path. When looking for the management
-    # module, we need look for the case where the project name is part
-    # of the app_name but the project directory itself isn't on the path.
-    try:
-        f, path, descr = imp.find_module(part, path)
-    except ImportError as e:
-        if os.path.basename(os.getcwd()) != part:
-            raise e
-    else:
-        if f:
-            f.close()
-
-    while parts:
-        part = parts.pop()
-        f, path, descr = imp.find_module(part, [path] if path else None)
-        if f:
-            f.close()
-    return path
+    packages = {}
+    mgmt_package = "%s.management.commands" % app_name
+    # The next line imports the *package*, not all modules in the package
+    __import__(mgmt_package)
+    path = getattr(sys.modules[mgmt_package], '__path__', None)
+    return [i[1] for i in iter_modules(path)]
 
 def load_command_class(app_name, name):
     """
@@ -99,7 +66,7 @@ def get_commands():
     """
     global _commands
     if _commands is None:
-        _commands = dict([(name, 'django.core') for name in find_commands(__path__[0])])
+        _commands = dict([(name, 'django.core') for name in find_commands('django.core')])
 
         # Find the installed apps
         from django.conf import settings
@@ -113,9 +80,8 @@ def get_commands():
         # Find and load the management module for each installed app.
         for app_name in apps:
             try:
-                path = find_management_module(app_name)
                 _commands.update(dict([(name, app_name)
-                                       for name in find_commands(path)]))
+                                       for name in find_commands(app_name)]))
             except ImportError:
                 pass # No management module - ignore this app

diff --git django/utils/autoreload.py django/utils/autoreload.py
index 6de15a2..1130feb 100644
--- django/utils/autoreload.py
+++ django/utils/autoreload.py
@@ -132,7 +132,22 @@ def reloader_thread():
 
 def restart_with_reloader():
     while True:
-        args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
+        # Fix for django+py2exe issue:
+        #
+        # Normally:
+        # sys.executable is 'python.exe' and the sys.argv[0] is the script name.
+        # The autoreload thread then runs 'python.exe script arguments'.
+        #
+        # When running from py2exe things are different:
+        # sys.executable is set to 'manage.exe' and sys.argv[0] is
+        # also 'manage.exe'.
+        # The autoreload thread should run "manage.exe arguments" and not
+        # "manage.exe manage.exe arguments". Now the interpreter and the script are
+        # basically one and the same.
+        #
+        #Original code:
+        # args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
+        args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + [i for i in sys.argv if not sys.executable.endswith(i)]
         if sys.platform == "win32":
             args = ['"%s"' % arg for arg in args]
         new_environ = os.environ.copy()
diff --git django/utils/translation/trans_real.py django/utils/translation/trans_real.py
index 195badf..6628118 100644
--- django/utils/translation/trans_real.py
+++ django/utils/translation/trans_real.py
@@ -142,7 +142,7 @@ def translation(language):
         # doesn't affect en-gb), even though they will both use the core "en"
         # translation. So we have to subvert Python's internal gettext caching.
         base_lang = lambda x: x.split('-', 1)[0]
-        if base_lang(lang) in [base_lang(trans) for trans in list(_translations)]:
+        if res and base_lang(lang) in [base_lang(trans) for trans in list(_translations)]:
             res._info = res._info.copy()
             res._catalog = res._catalog.copy()
 
