[Python-modules-commits] [python-django-extensions] 01/05: Import python-django-extensions_1.6.1.orig.tar.gz

Brian May bam at moszumanska.debian.org
Sun Jan 3 04:52:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

bam pushed a commit to branch master
in repository python-django-extensions.

commit e8e55ed79fca5962cfdf96bd3c9340e9a0c5b98b
Author: Brian May <bam at debian.org>
Date:   Sun Jan 3 15:46:38 2016 +1100

    Import python-django-extensions_1.6.1.orig.tar.gz
---
 .gitignore                                         |   1 +
 .travis.yml                                        |   9 ++
 CHANGELOG.md                                       |  18 ++++
 README.rst                                         |   2 +-
 django_extensions/__init__.py                      |   2 +-
 django_extensions/admin/__init__.py                |  10 +-
 django_extensions/admin/widgets.py                 |   6 --
 django_extensions/compat.py                        | 109 +++++++++++++++++++-
 .../management/commands/sample.py.tmpl             |   3 +-
 django_extensions/db/fields/json.py                |   2 +-
 django_extensions/management/base.py               |   2 +-
 .../management/commands/admin_generator.py         |   5 +-
 .../management/commands/drop_test_database.py      |  12 +--
 .../management/commands/dumpscript.py              |  16 +--
 django_extensions/management/commands/reset_db.py  |  12 +--
 .../management/commands/runserver_plus.py          |  38 +++++--
 ...{show_templatetags.py => show_template_tags.py} |  15 +--
 .../management/commands/show_templatetags.py       | 112 ++-------------------
 .../management/commands/unreferenced_files.py      |   7 +-
 .../management/commands/validate_templates.py      |   5 +-
 django_extensions/management/modelviz.py           |  22 ++--
 .../django_extensions/js/jquery-1.7.2.min.js       |   4 -
 django_extensions/utils/dia2django.py              |   2 +-
 django_extensions/utils/validatingtemplatetags.py  |   2 +-
 docs/AUTHORS                                       |   1 +
 docs/command_signals.rst                           |   4 +-
 docs/conf.py                                       |   4 +-
 docs/creating_release.txt                          |   4 +-
 docs/index.rst                                     |   2 +-
 docs/runserver_plus.rst                            |   2 +-
 setup.cfg                                          |   1 +
 tests/test_json_field.py                           |   1 +
 tests/test_management_command.py                   |   7 +-
 tox.ini                                            |  15 ++-
 34 files changed, 256 insertions(+), 201 deletions(-)

diff --git a/.gitignore b/.gitignore
index 3a6519e..7fd246f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ venv*
 .eggs/
 .idea/
 .coverage
+.cache/
 
diff --git a/.travis.yml b/.travis.yml
index 8a3dc3b..1de43c1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,14 @@
 language: python
 
+python:
+    - 3.5
+
 sudo: false
 
 env:
     - TOX_ENV=py27-flake8
     - TOX_ENV=py34-flake8
+    - TOX_ENV=py35-flake8
     - TOX_ENV=py27-dj14
     - TOX_ENV=py27-dj15
     - TOX_ENV=py27-dj16
@@ -16,6 +20,7 @@ env:
     - TOX_ENV=py34-dj16
     - TOX_ENV=py27-dj17
     - TOX_ENV=py27-dj18
+    - TOX_ENV=py27-dj19
     - TOX_ENV=py27-djmaster
     - TOX_ENV=py32-dj17
     - TOX_ENV=py32-dj18
@@ -25,7 +30,10 @@ env:
     - TOX_ENV=py33-djmaster
     - TOX_ENV=py34-dj17
     - TOX_ENV=py34-dj18
+    - TOX_ENV=py34-dj19
     - TOX_ENV=py34-djmaster
+    - TOX_ENV=py35-dj19
+    - TOX_ENV=py35-djmaster
     - TOX_ENV=pypy-dj17
     - TOX_ENV=pypy-dj18
     - TOX_ENV=pypy-djmaster
@@ -36,6 +44,7 @@ env:
 matrix:
   fast_finish: true
   allow_failures:
+    - env: TOX_ENV=py35-djmaster
     - env: TOX_ENV=py34-djmaster
     - env: TOX_ENV=py33-djmaster
     - env: TOX_ENV=py32-djmaster
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 49d08b2..b85bca1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,24 @@
 Changelog
 =========
 
+1.6.1
+-----
+
+Changes:
+ - Revert: JSONField, revert Django 1.9 fix as it breaks the field (ticket #781)
+
+
+1.6.0
+-----
+
+Changes:
+ - Fix: Django 1.9 compatibility
+ - New: runserver_plus, add --startup-messages to control when to show them
+ - New: added support for Python 3.5
+ - Improvement: show_template_tags, renamed from show_templatetags for consistancy
+ - Removed: jquery library (after dropping support for Django 1.5)
+
+
 1.5.9
 -----
 
diff --git a/README.rst b/README.rst
index c92ae51..0fcbf6a 100644
--- a/README.rst
+++ b/README.rst
@@ -36,7 +36,7 @@ minutes Eric walks you through a half a dozen command extensions. There is also
 Requirements
 ============
 
-Django Extensions requires Django 1.4 or later.
+Django Extensions requires Django 1.6 or later.
 
 
 Getting It
diff --git a/django_extensions/__init__.py b/django_extensions/__init__.py
index 9057a1d..81c14e0 100644
--- a/django_extensions/__init__.py
+++ b/django_extensions/__init__.py
@@ -1,5 +1,5 @@
 
-VERSION = (1, 5, 9)
+VERSION = (1, 6, 1)
 
 # Dynamically calculate the version based on VERSION tuple
 if len(VERSION) > 2 and VERSION[2] is not None:
diff --git a/django_extensions/admin/__init__.py b/django_extensions/admin/__init__.py
index 019c745..4581a81 100644
--- a/django_extensions/admin/__init__.py
+++ b/django_extensions/admin/__init__.py
@@ -15,14 +15,15 @@ from django.utils.translation import ugettext as _
 from django.utils.text import get_text_list
 from django.contrib.admin import ModelAdmin
 
+from django_extensions.admin.widgets import ForeignKeySearchInput
+from django_extensions.compat import get_model_compat
+
 try:
     from functools import update_wrapper
     assert update_wrapper
 except ImportError:
     from django.utils.functional import update_wrapper
 
-from django_extensions.admin.widgets import ForeignKeySearchInput
-
 
 class ForeignKeyAutocompleteAdmin(ModelAdmin):
     """Admin class for models using the autocomplete feature.
@@ -102,7 +103,10 @@ class ForeignKeyAutocompleteAdmin(ModelAdmin):
                     return "%s__search" % field_name[1:]
                 else:
                     return "%s__icontains" % field_name
-            model = models.get_model(app_label, model_name)
+
+            # As of Django 1.7 the 'get_model' method was moved to 'apps'
+            model = get_model_compat(app_label, model_name)
+
             queryset = model._default_manager.all()
             data = ''
             if query:
diff --git a/django_extensions/admin/widgets.py b/django_extensions/admin/widgets.py
index 01cec62..87a5505 100644
--- a/django_extensions/admin/widgets.py
+++ b/django_extensions/admin/widgets.py
@@ -1,4 +1,3 @@
-import django
 import six
 from django import forms
 from django.contrib.admin.sites import site
@@ -23,11 +22,6 @@ class ForeignKeySearchInput(ForeignKeyRawIdWidget):
                     'django_extensions/js/jquery.ajaxQueue.js',
                     'django_extensions/js/jquery.autocomplete.js']
 
-        # Use a newer version of jquery if django version <= 1.5.x
-        # When removing this compatibility code also remove jquery-1.7.2.min.js file.
-        if int(django.get_version()[2]) <= 5:
-            js_files.insert(0, 'django_extensions/js/jquery-1.7.2.min.js')
-
         return forms.Media(css={'all': ('django_extensions/css/jquery.autocomplete.css',)},
                            js=js_files)
 
diff --git a/django_extensions/compat.py b/django_extensions/compat.py
index 01017ce..a820848 100644
--- a/django_extensions/compat.py
+++ b/django_extensions/compat.py
@@ -1,9 +1,9 @@
 from __future__ import unicode_literals
 
 import sys
-
 import django
 from django.conf import settings
+from django.core.management.base import CommandError
 
 # flake8: noqa
 
@@ -16,11 +16,9 @@ OLD_PY2 = sys.version_info[:2] < (2, 7)
 if PY3:  # pragma: no cover
     from io import StringIO
     import importlib
-
 elif OLD_PY2:  # pragma: no cover
     from cStringIO import StringIO
     from django.utils import importlib
-
 else:  # pragma: no cover
     from cStringIO import StringIO
     import importlib
@@ -47,7 +45,27 @@ def list_apps():
         return [app.name for app in apps.get_app_configs()]
     except ImportError:
         # old way
-        return settings.INSTALLED_APPS
+        return list(settings.INSTALLED_APPS)
+
+
+def list_app_labels():
+    try:
+        # django >= 1.7, to support AppConfig
+        from django.apps import apps
+        return [app.label for app in apps.get_app_configs()]
+    except ImportError:
+        # old way
+        return [app.rsplit(".")[-1] for app in settings.INSTALLED_APPS]
+
+
+def get_app(app_label):
+    try:
+        # django >= 1.7
+        from django.apps import apps
+        return apps.get_app_config(app_label).models_module
+    except ImportError:
+        from django.db import models
+        return models.get_app(app_label)
 
 
 def get_apps():
@@ -60,6 +78,24 @@ def get_apps():
         return models.get_apps()
 
 
+def get_apps_from_cache():
+    try:
+        from django.apps import apps
+        return [app.models_module for app in apps.get_app_configs() if app.models_module]
+    except ImportError:
+        from django.db.models.loading import cache
+        return cache.get_apps()
+
+
+def get_models_from_cache(app):
+    try:
+        from django.apps import apps
+        return apps.get_models(app)
+    except ImportError:
+        from django.db.models.loading import cache
+        return cache.get_models(app)
+
+
 def get_app_models(app_labels=None):
     if app_labels is None:
         try:
@@ -93,3 +129,68 @@ def get_app_models(app_labels=None):
             app_models.extend(models.get_models(app, include_auto_created=True))
 
     return app_models
+
+
+def get_model_compat(app_label, model_name):
+    """Get a model on multiple Django versions."""
+    try:
+        # django >= 1.7
+        from django.apps import apps
+        return apps.get_model(app_label, model_name)
+    except ImportError:
+        from django.db.models import get_model
+        return get_model(app_label, model_name)
+
+
+def get_models_compat(app_label):
+    """Get models on multiple Django versions."""
+    try:
+        # django >= 1.7
+        from django.apps import apps
+        return apps.get_app_config(app_label).get_models()
+    except ImportError:
+        from django.db.models import get_models
+        return get_models(app_label)
+
+
+def get_models_for_app(app_label):
+    """Returns the models in the given app."""
+    try:
+        # django >= 1.7
+        from django.apps import apps
+        return apps.get_app_config(app_label).get_models()
+    except ImportError:
+        from django.db.models import get_app, get_models
+        return get_models(get_app(app_label))
+
+
+def load_tag_library(libname):
+    """Load a templatetag library on multiple Django versions.
+
+    Returns None if the library isn't loaded.
+    """
+    if django.VERSION < (1, 9):
+        from django.template.base import get_library, InvalidTemplateLibrary
+        try:
+            lib = get_library(libname)
+            return lib
+        except InvalidTemplateLibrary:
+            return None
+    else:
+        from django.template.backends.django import get_installed_libraries
+        from django.template.library import InvalidTemplateLibrary
+        try:
+            lib = get_installed_libraries()[libname]
+            lib = importlib.import_module(lib).register
+            return lib
+        except (InvalidTemplateLibrary, KeyError):
+            return None
+
+
+def add_to_builtins_compat(name):
+    if django.VERSION < (1, 9):
+        from django.template.base import add_to_builtins
+        add_to_builtins(name)
+    else:
+        from django.template import engines
+        engines['django'].engine.builtins.append(name)
diff --git a/django_extensions/conf/command_template/management/commands/sample.py.tmpl b/django_extensions/conf/command_template/management/commands/sample.py.tmpl
index eb9df1b..26e8cde 100644
--- a/django_extensions/conf/command_template/management/commands/sample.py.tmpl
+++ b/django_extensions/conf/command_template/management/commands/sample.py.tmpl
@@ -1,7 +1,8 @@
 from django.core.management.base import {{ base_command }}
 
+
 class Command({{ base_command }}):
     help = "My shiny new management command."
 
     def {{ handle_method }}:
-        raise NotImplementedError()
\ No newline at end of file
+        raise NotImplementedError()
diff --git a/django_extensions/db/fields/json.py b/django_extensions/db/fields/json.py
index 0b5a9d6..89eece7 100644
--- a/django_extensions/db/fields/json.py
+++ b/django_extensions/db/fields/json.py
@@ -100,7 +100,7 @@ class JSONField(six.with_metaclass(models.SubfieldBase, models.TextField)):
         # run through `dumps`
         if not isinstance(value, six.string_types):
             value = dumps(value)
-        return super(JSONField, self).get_db_prep_save(value, connection=connection)
+        return super(JSONField, self).get_db_prep_save(value, connection=connection, **kwargs)
 
     def south_field_triple(self):
         """Returns a suitable description of this field for South."""
diff --git a/django_extensions/management/base.py b/django_extensions/management/base.py
index a5593c6..a558b02 100644
--- a/django_extensions/management/base.py
+++ b/django_extensions/management/base.py
@@ -1,7 +1,7 @@
 import sys
 
 from django.core.management.base import BaseCommand
-from django.utils.log import getLogger
+from logging import getLogger
 
 logger = getLogger('django.commands')
 
diff --git a/django_extensions/management/commands/admin_generator.py b/django_extensions/management/commands/admin_generator.py
index d872d65..ed89f63 100644
--- a/django_extensions/management/commands/admin_generator.py
+++ b/django_extensions/management/commands/admin_generator.py
@@ -22,9 +22,8 @@ import sys
 from django.conf import settings
 from django.core.management.base import BaseCommand
 from django.db import models
-from django.db.models.loading import get_models
 
-from django_extensions.compat import get_apps
+from django_extensions.compat import get_apps, get_models_compat
 from django_extensions.management.color import color_style
 from django_extensions.management.utils import signalcommand
 
@@ -91,7 +90,7 @@ class AdminApp(UnicodeMixin):
         self.options = options
 
     def __iter__(self):
-        for model in get_models(self.app):
+        for model in get_models_compat(self.app):
             admin_model = AdminModel(model, **self.options)
 
             for model_re in self.model_res:
diff --git a/django_extensions/management/commands/drop_test_database.py b/django_extensions/management/commands/drop_test_database.py
index 9785c46..9ff26de 100644
--- a/django_extensions/management/commands/drop_test_database.py
+++ b/django_extensions/management/commands/drop_test_database.py
@@ -125,17 +125,17 @@ Type 'yes' to continue, or 'no' to cancel: """ % (database_name,))
             elif engine in ('postgresql_psycopg2', 'postgis'):
                 import psycopg2 as Database  # NOQA
 
-            conn_string = "dbname=template1"
+            conn_params = {'database': 'template1'}
             if user:
-                conn_string += " user=%s" % user
+                conn_params['user'] = user
             if password:
-                conn_string += " password='%s'" % password
+                conn_params['password'] = password
             if database_host:
-                conn_string += " host=%s" % database_host
+                conn_params['host'] = database_host
             if database_port:
-                conn_string += " port=%s" % database_port
+                conn_params['port'] = database_port
 
-            connection = Database.connect(conn_string)
+            connection = Database.connect(**conn_params)
             connection.set_isolation_level(0)  # autocommit false
             cursor = connection.cursor()
             drop_query = "DROP DATABASE IF EXISTS \"%s\";" % database_name
diff --git a/django_extensions/management/commands/dumpscript.py b/django_extensions/management/commands/dumpscript.py
index 8dc22bf..fcb43b1 100644
--- a/django_extensions/management/commands/dumpscript.py
+++ b/django_extensions/management/commands/dumpscript.py
@@ -1,4 +1,4 @@
-# -*- coding: UTF-8 -*-
+# -*- coding: utf-8 -*-
 """
       Title: Dumpscript management command
     Project: Hardytools (queryset-refactor version)
@@ -44,6 +44,9 @@ from django.db.models import (
 )
 
 from django_extensions.management.utils import signalcommand
+from django_extensions.compat import (
+    get_apps, get_model_compat, get_models_compat, get_models_for_app
+)
 
 try:
     from django.utils.encoding import smart_unicode, force_unicode  # NOQA
@@ -122,9 +125,6 @@ def get_models(app_labels):
         Or at least discovered with a get_or_create() call.
     """
 
-    from django.db.models import get_app, get_apps, get_model
-    from django.db.models import get_models as get_all_models
-
     # These models are not to be output, e.g. because they can be generated automatically
     # TODO: This should be "appname.modelname" string
     EXCLUDED_MODELS = (ContentType, )
@@ -134,7 +134,8 @@ def get_models(app_labels):
     # If no app labels are given, return all
     if not app_labels:
         for app in get_apps():
-            models += [m for m in get_all_models(app) if m not in EXCLUDED_MODELS]
+            models += [m for m in get_models_compat(app)
+                       if m not in EXCLUDED_MODELS]
         return models
 
     # Get all relevant apps
@@ -142,10 +143,11 @@ def get_models(app_labels):
         # If a specific model is mentioned, get only that model
         if "." in app_label:
             app_label, model_name = app_label.split(".", 1)
-            models.append(get_model(app_label, model_name))
+            models.append(get_model_compat(app_label, model_name))
         # Get all models for a given app
         else:
-            models += [m for m in get_all_models(get_app(app_label)) if m not in EXCLUDED_MODELS]
+            models += [m for m in get_models_for_app(app_label)
+                       if m not in EXCLUDED_MODELS]
 
     return models
 
diff --git a/django_extensions/management/commands/reset_db.py b/django_extensions/management/commands/reset_db.py
index f6ee2ba..f08893f 100644
--- a/django_extensions/management/commands/reset_db.py
+++ b/django_extensions/management/commands/reset_db.py
@@ -131,17 +131,17 @@ Type 'yes' to continue, or 'no' to cancel: """ % (database_name,))
             elif engine in ('postgresql', 'postgresql_psycopg2', 'postgis'):
                 import psycopg2 as Database  # NOQA
 
-            conn_string = "dbname=template1"
+            conn_params = {'database': 'template1'}
             if user:
-                conn_string += " user=%s" % user
+                conn_params['user'] = user
             if password:
-                conn_string += " password='%s'" % password
+                conn_params['password'] = password
             if database_host:
-                conn_string += " host=%s" % database_host
+                conn_params['host'] = database_host
             if database_port:
-                conn_string += " port=%s" % database_port
+                conn_params['port'] = database_port
 
-            connection = Database.connect(conn_string)
+            connection = Database.connect(**conn_params)
             connection.set_isolation_level(0)  # autocommit false
             cursor = connection.cursor()
             drop_query = "DROP DATABASE \"%s\";" % database_name
diff --git a/django_extensions/management/commands/runserver_plus.py b/django_extensions/management/commands/runserver_plus.py
index cfa5ff8..ef1d03f 100644
--- a/django_extensions/management/commands/runserver_plus.py
+++ b/django_extensions/management/commands/runserver_plus.py
@@ -75,6 +75,8 @@ class Command(BaseCommand):
                     help='Drop into ipdb shell at the start of any view.'),
         make_option('--pm', action='store_true', dest='pm', default=False,
                     help='Drop into (i)pdb shell if an exception is raised in a view.'),
+        make_option('--startup-messages', dest='startup_messages', action="store", default='reload',
+                    help='When to show startup messages: reload [default], once, always, never.')
     )
     if USE_STATICFILES:
         option_list += (
@@ -93,6 +95,18 @@ class Command(BaseCommand):
     def handle(self, addrport='', *args, **options):
         import django
 
+        startup_messages = options.get('startup_messages', 'reload')
+        if startup_messages == "reload":
+            self.show_startup_messages = os.environ.get('RUNSERVER_PLUS_SHOW_MESSAGES')
+        elif startup_messages == "once":
+            self.show_startup_messages = not os.environ.get('RUNSERVER_PLUS_SHOW_MESSAGES')
+        elif startup_messages == "never":
+            self.show_startup_messages = False
+        else:
+            self.show_startup_messages = True
+
+        os.environ['RUNSERVER_PLUS_SHOW_MESSAGES'] = '1'
+
         # Do not use default ending='\n', because StreamHandler() takes care of it
         if hasattr(self.stderr, 'ending'):
             self.stderr.ending = None
@@ -154,7 +168,8 @@ class Command(BaseCommand):
                 try:
                     set_werkzeug_log_color()
                 except:     # We are dealing with some internals, anything could go wrong
-                    print("Wrapping internal werkzeug logger for color highlighting has failed!")
+                    if self.show_startup_messages:
+                        print("Wrapping internal werkzeug logger for color highlighting has failed!")
                     pass
 
         except ImportError:
@@ -240,20 +255,22 @@ class Command(BaseCommand):
         reloader_interval = options.get('reloader_interval', 1)
 
         def inner_run():
-            print("Performing system checks...\n")
+            if self.show_startup_messages:
+                print("Performing system checks...\n")
             if hasattr(self, 'check'):
-                self.check(display_num_errors=True)
+                self.check(display_num_errors=self.show_startup_messages)
             else:
-                self.validate(display_num_errors=True)
+                self.validate(display_num_errors=self.show_startup_messages)
             if HAS_MIGRATIONS:
                 try:
                     self.check_migrations()
                 except ImproperlyConfigured:
                     pass
-            print("\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE))
-            print("Development server is running at %s" % (bind_url,))
-            print("Using the Werkzeug debugger (http://werkzeug.pocoo.org/)")
-            print("Quit the server with %s." % quit_command)
+            if self.show_startup_messages:
+                print("\nDjango version %s, using settings %r" % (django.get_version(), settings.SETTINGS_MODULE))
+                print("Development server is running at %s" % (bind_url,))
+                print("Using the Werkzeug debugger (http://werkzeug.pocoo.org/)")
+                print("Quit the server with %s." % quit_command)
             path = options.get('admin_media_path', '')
             if not path:
                 admin_media_path = os.path.join(django.__path__[0], 'contrib/admin/static/admin')
@@ -304,7 +321,8 @@ class Command(BaseCommand):
                         ssl_context = make_ssl_devcert(
                             os.path.join(dir_path, root), host='localhost')
                 except ImportError:
-                    print("Werkzeug version is less than 0.9, trying adhoc certificate.")
+                    if self.show_startup_messages:
+                        print("Werkzeug version is less than 0.9, trying adhoc certificate.")
                     ssl_context = "adhoc"
 
             else:
@@ -338,7 +356,7 @@ class Command(BaseCommand):
         """
         executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
         plan = executor.migration_plan(executor.loader.graph.leaf_nodes())
-        if plan:
+        if plan and self.show_startup_messages:
             self.stdout.write(self.style.NOTICE("\nYou have unapplied migrations; your app may not work properly until they are applied."))
             self.stdout.write(self.style.NOTICE("Run 'python manage.py migrate' to apply them.\n"))
 
diff --git a/django_extensions/management/commands/show_templatetags.py b/django_extensions/management/commands/show_template_tags.py
similarity index 90%
copy from django_extensions/management/commands/show_templatetags.py
copy to django_extensions/management/commands/show_template_tags.py
index bc09f28..11662d1 100644
--- a/django_extensions/management/commands/show_templatetags.py
+++ b/django_extensions/management/commands/show_template_tags.py
@@ -5,9 +5,9 @@ import six
 from django.conf import settings
 from django.core.management import color
 from django.core.management.base import BaseCommand
-from django.template.base import get_library
 from django.utils import termcolors
 
+from django_extensions.compat import load_tag_library
 from django_extensions.management.utils import signalcommand
 
 try:
@@ -92,19 +92,22 @@ class Command(BaseCommand):
                 tag_files = [i.rstrip('.py') for i in mod_files if i.endswith('.py') and i[0] != '_']
                 app_labeled = False
                 for taglib in tag_files:
-                    try:
-                        lib = get_library(taglib)
-                    except:
+                    lib = load_tag_library(taglib)
+                    if lib is None:
                         continue
+
                     if not app_labeled:
                         self.add_result('App: %s' % style.MODULE_NAME(app))
                         app_labeled = True
                     self.add_result('load: %s' % style.TAGLIB(taglib), 1)
-                    for items, label, style_func in [(lib.tags, 'Tag:', style.TAG), (lib.filters, 'Filter:', style.FILTER)]:
+                    libstuff = [
+                        (lib.tags, 'Tag:', style.TAG),
+                        (lib.filters, 'Filter:', style.FILTER)
+                    ]
+                    for items, label, style_func in libstuff:
                         for item in items:
                             self.add_result('%s %s' % (label, style_func(item)), 2)
                             doc = inspect.getdoc(items[item])
                             if doc:
                                 self.add_result(format_block(doc, 12))
         return self.results
-        # return "\n".join(results)
diff --git a/django_extensions/management/commands/show_templatetags.py b/django_extensions/management/commands/show_templatetags.py
index bc09f28..9754664 100644
--- a/django_extensions/management/commands/show_templatetags.py
+++ b/django_extensions/management/commands/show_templatetags.py
@@ -1,110 +1,16 @@
-import inspect
-import os
+import warnings
 
-import six
-from django.conf import settings
-from django.core.management import color
+from django.core.management import call_command
 from django.core.management.base import BaseCommand
-from django.template.base import get_library
-from django.utils import termcolors
-
-from django_extensions.management.utils import signalcommand
-
-try:
-    from django.utils.encoding import smart_text
-except ImportError:
-    smart_text = six.u
-
-
-def color_style():
-    style = color.color_style()
-    style.FILTER = termcolors.make_style(fg='yellow', opts=('bold',))
-    style.MODULE_NAME = termcolors.make_style(fg='green', opts=('bold',))
-    style.TAG = termcolors.make_style(fg='red', opts=('bold',))
-    style.TAGLIB = termcolors.make_style(fg='blue', opts=('bold',))
-    return style
-
-
-def format_block(block, nlspaces=0):
-    '''Format the given block of text, trimming leading/trailing
-    empty lines and any leading whitespace that is common to all lines.
-    The purpose is to let us list a code block as a multiline,
-    triple-quoted Python string, taking care of
-    indentation concerns.
-    http://code.activestate.com/recipes/145672/'''
-
-    import re
-
-    # separate block into lines
-    lines = smart_text(block).split('\n')
-
-    # remove leading/trailing empty lines
-    while lines and not lines[0]:
-        del lines[0]
-    while lines and not lines[-1]:
-        del lines[-1]
-
-    # look at first line to see how much indentation to trim
-    ws = re.match(r'\s*', lines[0]).group(0)
-    if ws:
-        lines = map(lambda x: x.replace(ws, '', 1), lines)
-
-    # remove leading/trailing blank lines (after leading ws removal)
-    # we do this again in case there were pure-whitespace lines
-    while lines and not lines[0]:
-        del lines[0]
-    while lines and not lines[-1]:
-        del lines[-1]
-
-    # account for user-specified leading spaces
-    flines = ['%s%s' % (' ' * nlspaces, line) for line in lines]
-
-    return '\n'.join(flines) + '\n'
 
 
 class Command(BaseCommand):
-    help = "Displays template tags and filters available in the current project."
-    results = ""
+    help = "Deprecated in favour of \"show_template_tags\". Displays template tags and filters available in the current project."
 
-    def add_result(self, s, depth=0):
-        self.results += '%s\n' % s.rjust(depth * 4 + len(s))
-
-    @signalcommand
     def handle(self, *args, **options):
-        if args:
-            appname, = args
-
-        style = color_style()
-
-        if getattr(settings, 'ADMIN_FOR', None):
-            settings_modules = [__import__(m, {}, {}, ['']) for m in settings.ADMIN_FOR]
-        else:
-            settings_modules = [settings]
-
-        for settings_mod in settings_modules:
-            for app in settings_mod.INSTALLED_APPS:
-                try:
-                    templatetag_mod = __import__(app + '.templatetags', {}, {}, [''])
-                except ImportError:
-                    continue
-                mod_path = inspect.getabsfile(templatetag_mod)
-                mod_files = os.listdir(os.path.dirname(mod_path))
-                tag_files = [i.rstrip('.py') for i in mod_files if i.endswith('.py') and i[0] != '_']
-                app_labeled = False
-                for taglib in tag_files:
-                    try:
-                        lib = get_library(taglib)
-                    except:
-                        continue
-                    if not app_labeled:
-                        self.add_result('App: %s' % style.MODULE_NAME(app))
-                        app_labeled = True
-                    self.add_result('load: %s' % style.TAGLIB(taglib), 1)
-                    for items, label, style_func in [(lib.tags, 'Tag:', style.TAG), (lib.filters, 'Filter:', style.FILTER)]:
-                        for item in items:
-                            self.add_result('%s %s' % (label, style_func(item)), 2)
-                            doc = inspect.getdoc(items[item])
-                            if doc:
-                                self.add_result(format_block(doc, 12))
-        return self.results
-        # return "\n".join(results)
+        warnings.warn(
+            "Deprecated: "
+            "\"show_templatetags\" is depreciated and will be "
+            "removed in future releases. Use \"show_template_tags\" instead.",
+            DeprecationWarning)
+        call_command('show_template_tags', **options)
diff --git a/django_extensions/management/commands/unreferenced_files.py b/django_extensions/management/commands/unreferenced_files.py
index 52ec4aa..a9f237a 100644
--- a/django_extensions/management/commands/unreferenced_files.py
+++ b/django_extensions/management/commands/unreferenced_files.py
@@ -4,9 +4,9 @@ from collections import defaultdict
 from django.conf import settings
 from django.core.management.base import NoArgsCommand
 from django.db import models
-from django.db.models.loading import cache
 
 from django_extensions.management.utils import signalcommand
+from django_extensions.compat import get_apps_from_cache, get_models_from_cache
 
 
 class Command(NoArgsCommand):
@@ -28,9 +28,8 @@ class Command(NoArgsCommand):
         # Get list of all fields (value) for each model (key)
         # that is a FileField or subclass of a FileField
         model_dict = defaultdict(list)
-        for app in cache.get_apps():
-            model_list = cache.get_models(app)
-            for model in model_list:
+        for app in get_apps_from_cache():
+            for model in get_models_from_cache(app):
                 for field in model._meta.fields:
                     if issubclass(field.__class__, models.FileField):
                         model_dict[model].append(field)
diff --git a/django_extensions/management/commands/validate_templates.py b/django_extensions/management/commands/validate_templates.py
index 82b7f30..e5d4ed0 100644
--- a/django_extensions/management/commands/validate_templates.py
+++ b/django_extensions/management/commands/validate_templates.py
@@ -3,9 +3,9 @@ from optparse import make_option
 
 from django.core.management.base import BaseCommand, CommandError
 from django.core.management.color import color_style
-from django.template.base import add_to_builtins
 from django.template.loader import get_template
 
+from django_extensions.compat import add_to_builtins_compat
 from django_extensions.management.utils import signalcommand
 from django_extensions.utils import validatingtemplatetags
 
@@ -50,7 +50,8 @@ class Command(BaseCommand):
 
         # Replace built in template tags with our own validating versions
         if options.get('check_urls', False):
-            add_to_builtins('django_extensions.utils.validatingtemplatetags')
+            add_to_builtins_compat(
+                'django_extensions.utils.validatingtemplatetags')
 
         for template_dir in template_dirs:
             for root, dirs, filenames in os.walk(template_dir):
diff --git a/django_extensions/management/modelviz.py b/django_extensions/management/modelviz.py
index 94de312..47674b0 100644
--- a/django_extensions/management/modelviz.py
+++ b/django_extensions/management/modelviz.py
@@ -11,8 +11,6 @@ import datetime
 import os
 
 import six
-from django.db import models
-from django.db.models import get_models
 from django.db.models.fields.related import (
     ForeignKey, ManyToManyField, OneToOneField, RelatedField,
 )
@@ -26,12 +24,11 @@ except ImportError:
     from django.utils.encoding import smart_str as force_bytes
 
 try:
-    from django.db.models.fields.generic import GenericRelation
-    assert GenericRelation
+    from django.contrib.contenttypes.fields import GenericRelation
 except ImportError:
     from django.contrib.contenttypes.generic import GenericRelation
 
-from django_extensions.compat import get_apps
+from django_extensions.compat import get_app, get_models_compat, list_app_labels
 
 
 __version__ = "1.0"
@@ -86,17 +83,14 @@ def generate_dot(app_labels, **kwargs):
                 return True
         return False
 
-    apps = []
     if all_applications:
-        apps = get_apps()
-
-    for app_label in app_labels:
-        app = models.get_app(app_label)
-        if app not in apps:
-            apps.append(app)
+        app_labels = list_app_labels()
 
     graphs = []
-    for app in apps:
+    for app_label in app_labels:
+        app = get_app(app_label)
+        if not app:
+            continue
         graph = Context({
             'name': '"%s"' % app.__name__,
             'app_name': "%s" % '.'.join(app.__name__.split('.')[:-1]),
@@ -104,7 +98,7 @@ def generate_dot(app_labels, **kwargs):
             'models': []
         })
 
-        appmodels = get_models(app)
+        appmodels = list(get_models_compat(app_label))
         abstract_models = []
         for appmodel in appmodels:
             abstract_models = abstract_models + [abstract_model for abstract_model in appmodel.__bases__ if hasattr(abstract_model, '_meta') and abstract_model._meta.abstract]
diff --git a/django_extensions/static/django_extensions/js/jquery-1.7.2.min.js b/django_extensions/static/django_extensions/js/jquery-1.7.2.min.js
deleted file mode 100644
index 16ad06c..0000000
--- a/django_extensions/static/django_extensions/js/jquery-1.7.2.min.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/*! jQuery v1.7.2 jquery.com | jquery.org/license */
-(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"<!doctype html>":"")+"<html><body>"),cl.close();d=cl.createElement(a),cl.bod [...]
-a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){ [...]
-.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagNa [...]
\ No newline at end of file
diff --git a/django_extensions/utils/dia2django.py b/django_extensions/utils/dia2django.py
index 532dee4..352436e 100644
--- a/django_extensions/utils/dia2django.py
+++ b/django_extensions/utils/dia2django.py
@@ -1,4 +1,4 @@
-# -*- coding: UTF-8 -*-
+# -*- coding: utf-8 -*-
 ##Author Igor Támara igor at tamarapatino.org
 ##Use this little program as you wish, if you
 #include it in your work, let others know you
diff --git a/django_extensions/utils/validatingtemplatetags.py b/django_extensions/utils/validatingtemplatetags.py
index 7cdf4d0..a49713d 100644
--- a/django_extensions/utils/validatingtemplatetags.py
+++ b/django_extensions/utils/validatingtemplatetags.py
@@ -1,5 +1,5 @@
 from django.template import defaulttags
-from django.template.base import Library, Node
+from django.template import Library, Node
 from django.templatetags import future
 
 register = Library()
diff --git a/docs/AUTHORS b/docs/AUTHORS
index 0304f32..5e91113 100644
--- a/docs/AUTHORS
+++ b/docs/AUTHORS
@@ -23,3 +23,4 @@ Wiktor Kołodziej (viciu)
 Marc Tudurí (marctc)
 Rick van Hattem (WoLpH)
 Rodolphe Quiédeville (rodo)
+Nik Nyby (nikolas)
\ No newline at end of file
diff --git a/docs/command_signals.rst b/docs/command_signals.rst
index 9609703..974b695 100644
--- a/docs/command_signals.rst
+++ b/docs/command_signals.rst
@@ -10,12 +10,12 @@ to hook into each commands execution.
 Basic Example
 -------------
 
-An example hooking into show_templatetags:
+An example hooking into show_template_tags:
 
 ::
 
   from django_extensions.management.signals import pre_command, post_command
-  from django_extensions.management.commands.show_templatetags import Command
+  from django_extensions.management.commands.show_template_tags import Command
   
   def pre_receiver(sender, args, kwargs):
     # I'm executed prior to the management command
diff --git a/docs/conf.py b/docs/conf.py
index 2357366..15bf1d0 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -45,9 +45,9 @@ copyright = u'Copyright (C) 2008-2015 Michael Trier, Bas van Oostveen and contri
 # built documents.
 #
 # The short X.Y version.
-version = '1.5'
+version = '1.6'
 # The full version, including alpha/beta/rc tags.
-release = '1.5.9'
+release = '1.6.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/docs/creating_release.txt b/docs/creating_release.txt
index ef2dc90..577a69c 100644
--- a/docs/creating_release.txt
+++ b/docs/creating_release.txt
@@ -14,7 +14,7 @@ Get a fresh copy::
 
 Run tests::
 
-  $ flake8 django-extensions
+  $ flake8 django_extensions
   $ tox --recreate
 
 Change version numbers in django_extensions/__init__.py and docs/conf.py::
@@ -33,7 +33,7 @@ Remove old build directory (if exists)::
 
 Prepare the release tarball::
 
-  $ python ./setup.py sdist
+  $ python ./setup.py sdist bdist_wheel
... 136 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-django-extensions.git



More information about the Python-modules-commits mailing list