=== modified file 'django/template/base.py'
--- django/template/base.py	2011-07-13 09:35:51 +0000
+++ django/template/base.py	2011-09-09 22:17:04 +0000
@@ -1012,21 +1012,35 @@
             return func
         return dec
 
+def is_library_missing(name):
+    """Check if library that failed to load cannot be found under a template
+    root or does exist but failes to import.
+
+    Non-existing condition is checked recursively for each subpackage in cases
+    like <temlpate_root>/subpacke/package/module.py.
+    """
+    # Don't bother to check if '.' is in name since any name will be prefixed
+    # with some template root.
+    path, module = name.rsplit('.', 1)
+    try:
+        package = import_module(path)
+        return not module_has_submodule(package, module)
+    except ImportError:
+        return is_library_missing(path)
+
 def import_library(taglib_module):
     """Load a template tag library module.
 
     Verifies that the library contains a 'register' attribute, and
     returns that attribute as the representation of the library
     """
-    app_path, taglib = taglib_module.rsplit('.',1)
-    app_module = import_module(app_path)
     try:
         mod = import_module(taglib_module)
     except ImportError, e:
         # If the ImportError is because the taglib submodule does not exist, that's not
         # an error that should be raised. If the submodule exists and raised an ImportError
         # on the attempt to load it, that we want to raise.
-        if not module_has_submodule(app_module, taglib):
+        if is_library_missing(taglib_module):
             return None
         else:
             raise InvalidTemplateLibrary("ImportError raised loading %s: %s" % (taglib_module, e))

=== modified file 'docs/ref/templates/builtins.txt'
--- docs/ref/templates/builtins.txt	2011-09-04 21:17:30 +0000
+++ docs/ref/templates/builtins.txt	2011-09-09 22:22:08 +0000
@@ -692,9 +692,10 @@
 Load a custom template tag set.
 
 For example, the following template would load all the tags and filters
-registered in ``somelibrary`` and ``otherlibrary``::
+registered in ``somelibrary`` and ``otherlibrary`` located in package
+``package``::
 
-    {% load somelibrary otherlibrary %}
+    {% load somelibrary package.otherlibrary %}
 
 .. versionchanged:: 1.3
 

=== added directory 'tests/regressiontests/templates/templatetags/subpackage'
=== added file 'tests/regressiontests/templates/templatetags/subpackage/__init__.py'
=== added file 'tests/regressiontests/templates/templatetags/subpackage/echo.py'
--- tests/regressiontests/templates/templatetags/subpackage/echo.py	1970-01-01 00:00:00 +0000
+++ tests/regressiontests/templates/templatetags/subpackage/echo.py	2011-09-09 23:06:16 +0000
@@ -0,0 +1,7 @@
+from django import template
+
+register = template.Library()
+
+@register.simple_tag
+def echo2(arg):
+    return arg

=== added file 'tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py'
--- tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py	1970-01-01 00:00:00 +0000
+++ tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py	2011-09-09 21:55:07 +0000
@@ -0,0 +1,1 @@
+import nonexistent.module

=== modified file 'tests/regressiontests/templates/tests.py'
--- tests/regressiontests/templates/tests.py	2011-08-30 12:09:45 +0000
+++ tests/regressiontests/templates/tests.py	2011-09-09 23:07:27 +0000
@@ -1188,17 +1188,22 @@
             'inheritance41': ("{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}", {'numbers': '123'}, '_new1_new2_new3_'),
 
             ### LOADING TAG LIBRARIES #################################################
+            'load01': ("{% load testtags subpackage.echo %}{% echo test %} {% echo2 \"test\" %}", {}, "test test"),
+            'load02': ("{% load subpackage.echo %}{% echo2 \"test\" %}", {}, "test"),
 
             # {% load %} tag, importing individual tags
-            'load1': ("{% load echo from testtags %}{% echo this that theother %}", {}, 'this that theother'),
-            'load2': ("{% load echo other_echo from testtags %}{% echo this that theother %} {% other_echo and another thing %}", {}, 'this that theother and another thing'),
-            'load3': ("{% load echo upper from testtags %}{% echo this that theother %} {{ statement|upper }}", {'statement': 'not shouting'}, 'this that theother NOT SHOUTING'),
+            'load03': ("{% load echo from testtags %}{% echo this that theother %}", {}, 'this that theother'),
+            'load04': ("{% load echo other_echo from testtags %}{% echo this that theother %} {% other_echo and another thing %}", {}, 'this that theother and another thing'),
+            'load05': ("{% load echo upper from testtags %}{% echo this that theother %} {{ statement|upper }}", {'statement': 'not shouting'}, 'this that theother NOT SHOUTING'),
+            'load06': ("{% load echo2 from subpackage.echo %}{% echo2 \"test\" %}", {}, "test"),
 
             # {% load %} tag errors
-            'load4': ("{% load echo other_echo bad_tag from testtags %}", {}, template.TemplateSyntaxError),
-            'load5': ("{% load echo other_echo bad_tag from %}", {}, template.TemplateSyntaxError),
-            'load6': ("{% load from testtags %}", {}, template.TemplateSyntaxError),
-            'load7': ("{% load echo from bad_library %}", {}, template.TemplateSyntaxError),
+            'load07': ("{% load echo other_echo bad_tag from testtags %}", {}, template.TemplateSyntaxError),
+            'load08': ("{% load echo other_echo bad_tag from %}", {}, template.TemplateSyntaxError),
+            'load09': ("{% load from testtags %}", {}, template.TemplateSyntaxError),
+            'load10': ("{% load echo from bad_library %}", {}, template.TemplateSyntaxError),
+            'load11': ("{% load subpackage.echo_invalid %}", {}, template.TemplateSyntaxError),
+            'load12': ("{% load subpackage.missing %}", {}, template.TemplateSyntaxError),
 
             ### I18N ##################################################################
 

