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

Brian May bam at moszumanska.debian.org
Sun Nov 6 10:36:37 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 6c5a19a5479a7f4c0db8c4cc709ec0ce6406b270
Author: Brian May <bam at debian.org>
Date:   Sun Nov 6 09:43:48 2016 +1100

    Import python-django-extensions_1.7.4.orig.tar.gz
---
 .pre-commit-config.yaml                            |  31 +++
 .travis.yml                                        |  60 ++---
 CHANGELOG.md                                       |  76 +++++-
 Makefile                                           |   2 +-
 README.rst                                         |  16 +-
 django_extensions/__init__.py                      |   4 +-
 django_extensions/admin/__init__.py                |  38 +--
 django_extensions/admin/filter.py                  |   6 +-
 django_extensions/admin/widgets.py                 |   7 +-
 django_extensions/compat.py                        | 214 +---------------
 django_extensions/conf/app_template/forms.py.tmpl  |   2 +-
 django_extensions/conf/app_template/urls.py.tmpl   |   5 +-
 .../management/commands/sample.py.tmpl             |   5 +-
 .../templatetags/sample.py.tmpl                    |   1 -
 django_extensions/db/__init__.py                   |   1 -
 django_extensions/db/fields/__init__.py            |  96 +-------
 django_extensions/db/fields/encrypted.py           |  37 +--
 django_extensions/db/fields/json.py                |  75 +++---
 django_extensions/db/models.py                     |  20 +-
 django_extensions/jobs/__init__.py                 |   1 -
 django_extensions/jobs/daily/__init__.py           |   1 -
 django_extensions/jobs/daily/cache_cleanup.py      |  10 +-
 django_extensions/jobs/daily/daily_cleanup.py      |   9 +-
 django_extensions/jobs/hourly/__init__.py          |   1 -
 django_extensions/jobs/minutely/__init__.py        |   1 -
 django_extensions/jobs/monthly/__init__.py         |   1 -
 django_extensions/jobs/weekly/__init__.py          |   1 -
 django_extensions/jobs/yearly/__init__.py          |   1 -
 django_extensions/logging/__init__.py              |   1 -
 django_extensions/logging/filters.py               |   2 +-
 django_extensions/management/__init__.py           |   1 -
 django_extensions/management/base.py               |   2 +-
 django_extensions/management/color.py              |  15 +-
 django_extensions/management/commands/__init__.py  |   1 -
 .../management/commands/admin_generator.py         |  66 ++---
 django_extensions/management/commands/clean_pyc.py |   5 +-
 .../management/commands/clear_cache.py             |   2 +-
 .../management/commands/compile_pyc.py             |   5 +-
 .../management/commands/create_app.py              |  39 +--
 .../management/commands/create_command.py          |  54 ++--
 .../management/commands/create_jobs.py             |  12 +-
 .../management/commands/create_template_tags.py    |  12 +-
 .../management/commands/describe_form.py           |  15 +-
 .../management/commands/drop_test_database.py      |  18 +-
 .../management/commands/dumpscript.py              |  96 ++------
 .../management/commands/export_emails.py           |   8 +-
 .../management/commands/find_template.py           |  13 +-
 .../management/commands/generate_secret_key.py     |   5 +-
 .../management/commands/graph_models.py            |  20 +-
 .../management/commands/mail_debug.py              |   6 +-
 django_extensions/management/commands/notes.py     |   7 +-
 django_extensions/management/commands/passwd.py    |  24 +-
 .../management/commands/pipchecker.py              |   6 +-
 .../management/commands/print_settings.py          |  20 +-
 .../management/commands/print_user_for_session.py  |  28 +--
 django_extensions/management/commands/reset_db.py  |  31 ++-
 django_extensions/management/commands/runjob.py    |  27 +-
 django_extensions/management/commands/runjobs.py   |  40 ++-
 .../management/commands/runprofileserver.py        |  59 +----
 django_extensions/management/commands/runscript.py |  72 +++---
 .../management/commands/runserver_plus.py          | 273 ++++++++++-----------
 .../management/commands/set_default_site.py        |   6 +-
 .../management/commands/set_fake_emails.py         |   8 +-
 .../management/commands/set_fake_passwords.py      |   9 +-
 .../management/commands/shell_plus.py              |  45 ++--
 .../management/commands/show_template_tags.py      |  11 +-
 .../management/commands/show_templatetags.py       |   2 +-
 django_extensions/management/commands/show_urls.py |  13 +-
 django_extensions/management/commands/sqlcreate.py |   8 +-
 django_extensions/management/commands/sqldiff.py   |  70 ++----
 django_extensions/management/commands/sqldsn.py    |   7 +-
 django_extensions/management/commands/sync_s3.py   |   8 +-
 django_extensions/management/commands/syncdata.py  |  32 +--
 .../management/commands/unreferenced_files.py      |  16 +-
 .../management/commands/update_permissions.py      |  34 +--
 .../management/commands/validate_templates.py      |  27 +-
 .../management/email_notifications.py              |   5 +-
 django_extensions/management/jobs.py               |   5 +-
 django_extensions/management/modelviz.py           |  41 +---
 django_extensions/management/mysql.py              |   2 +-
 django_extensions/management/notebook_extension.py |   2 +-
 django_extensions/management/shells.py             |  55 ++---
 django_extensions/management/signals.py            |   2 +-
 django_extensions/management/technical_response.py |   2 +-
 django_extensions/management/utils.py              |   2 +-
 django_extensions/models.py                        |   1 -
 django_extensions/mongodb/__init__.py              |   1 -
 django_extensions/mongodb/fields/__init__.py       |   2 +-
 django_extensions/mongodb/fields/encrypted.py      |   2 +-
 django_extensions/mongodb/fields/json.py           |  11 +-
 django_extensions/mongodb/models.py                |  18 +-
 django_extensions/settings.py                      |   2 +-
 django_extensions/south_migrations/0001_empty.py   |  17 --
 django_extensions/south_migrations/__init__.py     |   1 -
 .../django_extensions/css/jquery.autocomplete.css  |   2 +-
 .../static/django_extensions/js/jquery.bgiframe.js |  39 +++
 .../django_extensions/js/jquery.bgiframe.min.js    |  10 -
 django_extensions/templatetags/__init__.py         |   1 -
 django_extensions/templatetags/highlighting.py     |  11 +-
 django_extensions/templatetags/indent_text.py      |   5 +-
 django_extensions/templatetags/syntax_color.py     |   2 +-
 django_extensions/templatetags/truncate_letters.py |  13 +-
 django_extensions/templatetags/widont.py           |  17 +-
 django_extensions/utils/__init__.py                |   1 -
 django_extensions/utils/deprecation.py             |   8 +
 django_extensions/utils/dia2django.py              |   2 +-
 django_extensions/utils/text.py                    |  11 +-
 django_extensions/utils/validatingtemplatetags.py  |  51 ++--
 django_extensions/validators.py                    |   2 +-
 docs/admin_extensions.rst                          |   2 +-
 docs/command_extensions.rst                        |   7 +-
 docs/conf.py                                       |   4 +-
 docs/creating_release.txt                          |   1 -
 docs/field_extensions.rst                          |   3 +
 docs/index.rst                                     |   2 +-
 docs/runprofileserver.rst                          |  10 +-
 docs/runscript.rst                                 |  11 +-
 docs/runserver_plus.rst                            |  46 ++--
 docs/shell_plus.rst                                |  28 ++-
 docs/validate_templates.rst                        |  12 +-
 setup.cfg                                          |   4 +-
 setup.py                                           |  14 +-
 tests/__init__.py                                  |  11 +-
 tests/management/__init__.py                       |   1 -
 tests/management/commands/__init__.py              |   1 -
 tests/management/commands/error_raising_command.py |   2 +-
 tests/management/test_modelviz.py                  |  28 +++
 tests/test_autoslug_fields.py                      |  18 +-
 tests/test_clean_pyc.py                            |   2 +-
 tests/test_color.py                                |  23 ++
 tests/test_compat.py                               |  25 ++
 tests/test_compile_pyc.py                          |   2 +-
 ...est_find_template.py => test_create_command.py} |   8 +-
 tests/test_dumpscript.py                           |   2 +-
 tests/test_encrypted_fields.py                     |   7 +-
 tests/test_find_template.py                        |   2 +-
 tests/test_json_field.py                           |  86 ++++++-
 tests/test_management_command.py                   |  99 +++++++-
 tests/test_models.py                               |   2 +-
 tests/test_randomchar_field.py                     |   2 +-
 tests/test_runscript.py                            |   9 +-
 tests/test_shortuuid_field.py                      |   2 +-
 tests/test_template_rendering.py                   |  16 ++
 tests/test_templatetags.py                         |  11 +-
 tests/test_timestamped_model.py                    |   2 +-
 tests/test_uuid_field.py                           |   2 +-
 tests/testapp/__init__.py                          |   3 +-
 tests/testapp/apps.py                              |  11 +-
 tests/testapp/models.py                            |   2 +-
 tests/testapp/scripts/__init__.py                  |   1 -
 tests/testapp/scripts/sample_script.py             |   2 +-
 tests/testapp/settings.py                          |  22 +-
 tests/testapp/urls.py                              |  27 +-
 tests/testapp_with_no_models_file/__init__.py      |   0
 tests/testapp_with_no_models_file/admin.py         |   7 +
 tox.ini                                            |  14 +-
 156 files changed, 1413 insertions(+), 1532 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..965cbfb
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,31 @@
+-   repo: git://github.com/pre-commit/pre-commit-hooks
+    sha: 493665a5fc24deb2204fc48b8398be77e6c9e5d5
+    hooks:
+    -   id: trailing-whitespace
+    -   id: check-added-large-files
+        args:
+        - --maxkb=128
+    -   id: check-ast
+    -   id: check-case-conflict
+    -   id: check-docstring-first
+    -   id: check-json
+    -   id: check-merge-conflict
+    -   id: check-xml
+    -   id: check-yaml
+    -   id: detect-private-key
+    -   id: end-of-file-fixer
+    -   id: fix-encoding-pragma
+    -   id: flake8
+    -   id: name-tests-test
+        args:
+        - --django
+        exclude: '^tests/testapp|^tests/management/'
+-   repo: git://github.com/Lucas-C/pre-commit-hooks.git
+    sha: 0f5055d31f39ea3ac1f5335a0cca320200cd0c51
+    hooks:
+    -   id: forbid-crlf
+-   repo: git://github.com/trbs/pre-commit-hooks-trbs.git
+    sha: c94ad5f83406a96b0750869e8930669af074975b
+    hooks:
+    -   id: forbid-executables
+        exclude: manage.py|setup.py
diff --git a/.travis.yml b/.travis.yml
index a1e7814..aa867a5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,49 +1,53 @@
 language: python
 
 python:
-    - 3.5
+  - 3.5
 
 sudo: false
 
 env:
-    - TOX_ENV=py27-flake8
-    - TOX_ENV=py34-flake8
-    - TOX_ENV=py35-flake8
-    - TOX_ENV=py27-dj16
-    - TOX_ENV=py32-dj16
-    - TOX_ENV=py33-dj16
-    - 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
-    - TOX_ENV=py33-dj17
-    - TOX_ENV=py33-dj18
-    - 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
-    - TOX_ENV=pypy3-dj17
-    - TOX_ENV=pypy3-dj18
-    - TOX_ENV=pypy3-djmaster
+  - TOX_ENV=py27-flake8
+  - TOX_ENV=py34-flake8
+  - TOX_ENV=py35-flake8
+  - TOX_ENV=precommit
+  - TOX_ENV=py27-dj18
+  - TOX_ENV=py27-dj19
+  - TOX_ENV=py27-dj110
+  - TOX_ENV=py27-djmaster
+  - TOX_ENV=py32-dj18
+  - TOX_ENV=py33-dj18
+  - TOX_ENV=py34-dj18
+  - TOX_ENV=py34-dj19
+  - TOX_ENV=py34-dj110
+  - TOX_ENV=py34-djmaster
+  - TOX_ENV=py35-dj18
+  - TOX_ENV=py35-dj19
+  - TOX_ENV=py35-dj110
+  - TOX_ENV=py35-djmaster
+  - TOX_ENV=pypy-dj18
+  - TOX_ENV=pypy-dj19
+  - TOX_ENV=pypy-dj110
+  - TOX_ENV=pypy-djmaster
+  # - TOX_ENV=pypy3-dj18
+  # - TOX_ENV=pypy3-dj19
+  # - TOX_ENV=pypy3-dj110
+  - TOX_ENV=pypy3-djmaster
 
 matrix:
   fast_finish: true
   allow_failures:
+    - env: TOX_ENV=py32-dj18
     - env: TOX_ENV=py35-djmaster
     - env: TOX_ENV=py34-djmaster
     - env: TOX_ENV=py27-djmaster
     - env: TOX_ENV=pypy-djmaster
+    # pypy3 is not >=3.4 compatible yet
+    # - env: TOX_ENV=pypy3-dj19
+    # - env: TOX_ENV=pypy3-dj110
     - env: TOX_ENV=pypy3-djmaster
 
 install:
+  # virtualenv<14.0.0 is for Python 3.2 compatibility
   - pip install "virtualenv<14.0.0" tox coveralls
 
 script:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa2158b..fecd442 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,14 +1,78 @@
 Changelog
 =========
 
+1.7.3
+-----
+
+Changes:
+ - Fix: ForeignKeySearchInput, fix bug with constructing search_path urls
+ - Docs: runscript, fix runscript example
+ - Deprecation: JSONField, Django now includes JSONField our field is now deprecated
+
+
+1.7.2
+-----
+
+Changes:
+ - Fix: passwd, Update passwd command up to Django>=1.8
+ - Improvement: shell_plus, add settings.SHELL_PLUS_PRINT_SQL config option
+ - Improvement: shell_plus, allow to specifies the connection file to use if using the --kernel option
+
+
+1.7.1
+-----
+
+Changes:
+ - Fix: sqldiff, fix optional app_label arguments
+ - Fix: runscript, remove args from command class
+ - Doc: runscript, remove = from --script-args example
+
+
+1.7.0
+-----
+
+The "Letting go of the past" release.
+
+From this moment on Django Extensions requires version 1.8 or higher.
+A lot of work has been done to remove old backwards compatibility code and
+make sure that Django Extensions uses the current Django API's. This should
+result in better and easier to maintain code (and hopefully less bugs :).
+
+This release touches a lot of code if you have any issues please report them
+at https://github.com/django-extensions/django-extensions/issues
+
+We still need more tests to make sure we don't break people's projects when
+refactoring. If you have some spare time please contribute tests !
+
+Changes:
+ - Cleanup: removing backwards compatibility hacks for (now) unsupported versions of Django
+ - Cleanup: use six instead of home grown functions
+ - Fix: AutoSlugField, allow_duplicates didn't set slug value to model instance
+ - Fix: MongoDB fields, verbose_name on mongoengine fields does not seem to be supported
+ - Fix: MongoDB fields, fix relative import problem with json.py
+ - Improvement: Start using pre-commit
+ - Improvement: syncdata, Replace custom transaction logic with transaction.atomic
+ - Improvement: Django 1.10, use from_db_value instead of models.SubfieldBase
+ - Improvement: print_user_session, support for non standard user model
+ - Improvement: widont, tests to work with py2 and py3
+ - Improvement: runserver_plus, prevent 2nd reload of debugger on runserver_plus
+ - Improvement: runserver_plus, prevent killing the server when request.META values are evaluated
+ - Improvement: reset_db, add argument to make closing sessions optional
+ - Improvement: print_settings, Fix positional arguments
+ - Improvement: runscript, migrate to argparse and add_arguments
+ - Improvement: graph_models, do not rely on .models_module for inclusion in output
+ - Improvement: jsonfield, fix issues with mutable default
+ - Docs: Convert readthedocs links for their .org -> .io migration
+
+
 1.6.7
 -----
 
 Changes:
-    - Fix: describe_form, fix No module named 'django.db.models.loading' error
-    - Improvement: shell_plus,  Add a setting to prefix all models in an application #887
-    - Improvement: pipchecker, check for requirements-{dev,prod}.txt as well
-    - Docs: pipchecker, update documentation
+ - Fix: describe_form, fix No module named 'django.db.models.loading' error
+ - Improvement: shell_plus,  Add a setting to prefix all models in an application #887
+ - Improvement: pipchecker, check for requirements-{dev,prod}.txt as well
+ - Docs: pipchecker, update documentation
 
 1.6.6
 -----
@@ -273,7 +337,7 @@ Changes:
  - New: validators.py, NoControlCharactersValidator and NoWhitespaceValidator
  - New: EmailNotificationCommand class, email exceptions from Django Commands
  - Improvement: runserver_plus, enable threading by default and added --nothreading
- - Improvement: runscript, better detection when import error occured in script 
+ - Improvement: runscript, better detection when import error occured in script
  - Improvement: runscript, use EmailNotificationCommand class
  - Deprecation: deprecated UUIDField since Django 1.8 will have a native version.
  - Removed: completely remove support for automatically finding project root.
@@ -367,7 +431,7 @@ Changes:
 
 Changes:
  - Feature: shell_plus, add --kernel option to start as standalone IPython kernel
- - Feature: reset_db, Programatically determine PostGIS template 
+ - Feature: reset_db, Programatically determine PostGIS template
  - Feature: sqldiff, add support for PointField and MultiPolygonField
  - Test: renamed test app
  - Fix: runserver_plus, --print-sql for Django 1.7
diff --git a/Makefile b/Makefile
index 1865c1a..e6c4a1e 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,7 @@ clean-test:
 	rm -fr htmlcov/
 
 test:
-	python setup.py test --pytest-args="tests --ds=tests.testapp.settings --cov=django_extensions"
+	python setup.py test --pytest-args="tests django_extensions --ds=tests.testapp.settings --cov=django_extensions"
 
 coverage:
 	coverage run --source django_extensions setup.py test
diff --git a/README.rst b/README.rst
index f722439..a455ca1 100644
--- a/README.rst
+++ b/README.rst
@@ -5,7 +5,7 @@
 .. image:: https://img.shields.io/pypi/l/django-extensions.svg
    :target: https://raw.githubusercontent.com/django-extensions/django-extensions/master/LICENSE
 
-.. image:: https://secure.travis-ci.org/django-extensions/django-extensions.png?branch=master
+.. image:: https://secure.travis-ci.org/django-extensions/django-extensions.svg?branch=master
     :alt: Build Status
     :target: http://travis-ci.org/django-extensions/django-extensions
 
@@ -21,7 +21,7 @@
     :target: https://pypi.python.org/pypi/django-extensions/
     :alt: Supports Wheel format
 
-.. image:: https://coveralls.io/repos/django-extensions/django-extensions/badge.png?branch=master
+.. image:: https://coveralls.io/repos/django-extensions/django-extensions/badge.svg?branch=master
    :target: https://coveralls.io/r/django-extensions/django-extensions?branch=master
    :alt: Coverage
 
@@ -31,16 +31,16 @@ Django Extensions is a collection of custom extensions for the Django Framework.
 Getting Started
 ===============
 
-The easiest way to figure out what Django Extensions are all about is to watch the 
-`excellent screencast by Eric Holscher`__ (`watch the video on vimeo`__). In a couple 
-minutes Eric walks you through a half a dozen command extensions. There is also a 
+The easiest way to figure out what Django Extensions are all about is to watch the
+`excellent screencast by Eric Holscher`__ (`watch the video on vimeo`__). In a couple
+minutes Eric walks you through a half a dozen command extensions. There is also a
 `short screencast on GoDjango`__ to help show you even more.
 
 
 Requirements
 ============
 
-Django Extensions requires Django 1.6 or later.
+Django Extensions requires Django 1.8 or later.
 
 
 Getting It
@@ -62,7 +62,7 @@ If you want to install it from source, grab the git repository from GitHub and r
 Installing It
 =============
 
-To enable `django_extensions` in your project you need to add it to `INSTALLED_APPS` in your projects 
+To enable `django_extensions` in your project you need to add it to `INSTALLED_APPS` in your projects
 `settings.py` file::
 
     INSTALLED_APPS = (
@@ -112,7 +112,7 @@ Documentation
 
 You can view documentation online at:
 
-- http://django-extensions.readthedocs.org
+- https://django-extensions.readthedocs.io
 
 Or you can look at the docs/ directory in the repository.
 
diff --git a/django_extensions/__init__.py b/django_extensions/__init__.py
index 2500de0..92443a5 100644
--- a/django_extensions/__init__.py
+++ b/django_extensions/__init__.py
@@ -1,5 +1,5 @@
-# coding=utf-8
-VERSION = (1, 6, 7)
+# -*- coding: utf-8 -*-
+VERSION = (1, 7, 4)
 
 # 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 a147034..4e25bb4 100644
--- a/django_extensions/admin/__init__.py
+++ b/django_extensions/admin/__init__.py
@@ -1,12 +1,13 @@
-# coding=utf-8
+# -*- coding: utf-8 -*-
 #
 # Autocomplete feature for admin panel
 #
 import six
 import operator
+from functools import update_wrapper
 from six.moves import reduce
 
-import django
+from django.apps import apps
 from django.http import HttpResponse, HttpResponseNotFound
 from django.conf import settings
 from django.db import models
@@ -17,13 +18,6 @@ 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
 
 
 class ForeignKeyAutocompleteAdmin(ModelAdmin):
@@ -63,25 +57,10 @@ class ForeignKeyAutocompleteAdmin(ModelAdmin):
                 return self.admin_site.admin_view(view)(*args, **kwargs)
             return update_wrapper(wrapper, view)
 
-        # model._meta.module_name is deprecated in django version 1.7 and removed in django version 1.8.
-        # It is replaced by model._meta.model_name
-        if django.VERSION < (1, 7):
-            info = self.model._meta.app_label, self.model._meta.module_name
-        else:
-            info = self.model._meta.app_label, self.model._meta.model_name
-
-        _url = url(r'foreignkey_autocomplete/$', wrap(self.foreignkey_autocomplete), name='%s_%s_autocomplete' % info)
-
-        # django.conf.urls.patterns is deprecated in django version 1.9 and removed in django version 1.10.
-        # It is replaced by a simple Python list
-        if django.VERSION < (1, 9):
-            from django.conf.urls import patterns
-            urlpatterns = patterns('', _url)
-        else:
-            urlpatterns = [_url]
-
-        urlpatterns += super(ForeignKeyAutocompleteAdmin, self).get_urls()
-        return urlpatterns
+        return [
+            url(r'foreignkey_autocomplete/$', wrap(self.foreignkey_autocomplete),
+                name='%s_%s_autocomplete' % (self.model._meta.app_label, self.model._meta.model_name))
+        ] + super(ForeignKeyAutocompleteAdmin, self).get_urls()
 
     def foreignkey_autocomplete(self, request):
         """
@@ -114,8 +93,7 @@ class ForeignKeyAutocompleteAdmin(ModelAdmin):
                 else:
                     return "%s__icontains" % field_name
 
-            # As of Django 1.7 the 'get_model' method was moved to 'apps'
-            model = get_model_compat(app_label, model_name)
+            model = apps.get_model(app_label, model_name)
 
             queryset = model._default_manager.all()
             data = ''
diff --git a/django_extensions/admin/filter.py b/django_extensions/admin/filter.py
index 571e235..8af8eb5 100644
--- a/django_extensions/admin/filter.py
+++ b/django_extensions/admin/filter.py
@@ -2,11 +2,7 @@
 from __future__ import unicode_literals
 
 from django.contrib.admin import FieldListFilter
-try:
-    from django.contrib.admin.utils import prepare_lookup_value
-except ImportError:
-    # django < 1.7
-    from django.contrib.admin.util import prepare_lookup_value
+from django.contrib.admin.utils import prepare_lookup_value
 from django.utils.translation import ugettext_lazy as _
 
 
diff --git a/django_extensions/admin/widgets.py b/django_extensions/admin/widgets.py
index c1e4676..969cc2b 100644
--- a/django_extensions/admin/widgets.py
+++ b/django_extensions/admin/widgets.py
@@ -1,5 +1,6 @@
-# coding=utf-8
+# -*- coding: utf-8 -*-
 import six
+from six.moves import urllib
 from django import forms
 from django.contrib.admin.sites import site
 from django.contrib.admin.widgets import ForeignKeyRawIdWidget
@@ -20,7 +21,7 @@ class ForeignKeySearchInput(ForeignKeyRawIdWidget):
     search_path = None
 
     def _media(self):
-        js_files = ['django_extensions/js/jquery.bgiframe.min.js',
+        js_files = ['django_extensions/js/jquery.bgiframe.js',
                     'django_extensions/js/jquery.ajaxQueue.js',
                     'django_extensions/js/jquery.autocomplete.js']
 
@@ -47,7 +48,7 @@ class ForeignKeySearchInput(ForeignKeyRawIdWidget):
         model_name = opts.object_name.lower()
         related_url = reverse('admin:%s_%s_changelist' % (app_label, model_name))
         if not self.search_path:
-            self.search_path = '%s/foreignkey_autocomplete/' % related_url
+            self.search_path = urllib.parse.urljoin(related_url, 'foreignkey_autocomplete/')
         params = self.url_parameters()
         if params:
             url = '?' + '&'.join(['%s=%s' % (k, v) for k, v in params.items()])
diff --git a/django_extensions/compat.py b/django_extensions/compat.py
index aef2cac..94ff8bf 100644
--- a/django_extensions/compat.py
+++ b/django_extensions/compat.py
@@ -1,170 +1,15 @@
-# coding=utf-8
+# -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-import sys
-from optparse import make_option
+import importlib
 import django
-from django.conf import settings
-from django.core.management.base import (BaseCommand, AppCommand, LabelCommand,
-                                         CommandError)
-
-# flake8: noqa
 
-#
-# Python compatibility
-#
-PY3 = sys.version_info[0] == 3
-OLD_PY2 = sys.version_info[:2] < (2, 7)
+from django.conf import settings
 
-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
 
 #
 # Django compatibility
 #
-try:  # Django 1.5
-    from django.contrib.auth import get_user_model
-except ImportError:  # pragma: no cover
-    assert django.VERSION < (1, 5)
-    from django.contrib.auth.models import User
-    User.USERNAME_FIELD = "username"
-    User.get_username = lambda self: self.username
-
-    def get_user_model():
-        return User
-
-
-def list_apps():
-    try:
-        # django >= 1.7, to support AppConfig
-        from django.apps import apps
-    except ImportError:
-        # old way
-        return list(settings.INSTALLED_APPS)
-    else:
-        return [app.name for app in apps.get_app_configs()]
-
-
-def list_app_labels():
-    try:
-        # django >= 1.7, to support AppConfig
-        from django.apps import apps
-    except ImportError:
-        # old way
-        return [app.rsplit(".")[-1] for app in settings.INSTALLED_APPS]
-    else:
-        return [app.label for app in apps.get_app_configs()]
-
-
-def get_app(app_label):
-    try:
-        # django >= 1.7
-        from django.apps import apps
-    except ImportError:
-        from django.db import models
-        return models.get_app(app_label)
-    else:
-        return apps.get_app_config(app_label).models_module
-
-
-def get_apps():
-    try:
-        # django >= 1.7, to support AppConfig
-        from django.apps import apps
-    except ImportError:
-        from django.db import models
-        return models.get_apps()
-    else:
-        return [app.models_module for app in apps.get_app_configs() if app.models_module]
-
-
-def get_apps_from_cache():
-    try:
-        from django.apps import apps
-    except ImportError:
-        from django.db.models.loading import cache
-        return cache.get_apps()
-    else:
-        return [app.models_module for app in apps.get_app_configs() if app.models_module]
-
-
-def get_models_from_cache(app):
-    try:
-        from django.apps import apps
-    except ImportError:
-        from django.db.models.loading import cache
-        return cache.get_models(app)
-    else:
-        return apps.get_models(app)
-
-
-def get_app_models(app_labels=None):
-    if app_labels is None:
-        try:
-            # django >= 1.7, to support AppConfig
-            from django.apps import apps
-        except ImportError:
-            from django.db import models
-            return models.get_models(include_auto_created=True)
-        else:
-            return apps.get_models(include_auto_created=True)
-
-    if not isinstance(app_labels, (list, tuple, set)):
-        app_labels = [app_labels]
-
-    app_models = []
-    try:
-        # django >= 1.7, to support AppConfig
-        from django.apps import apps
-    except ImportError:
-        from django.db import models
-
-        try:
-            app_list = [models.get_app(app_label) for app_label in app_labels]
-        except (models.ImproperlyConfigured, ImportError) as e:
-            raise CommandError("%s. Are you sure your INSTALLED_APPS setting is correct?" % e)
-
-        for app in app_list:
-            app_models.extend(models.get_models(app, include_auto_created=True))
-    else:
-        for app_label in app_labels:
-            app_config = apps.get_app_config(app_label)
-            app_models.extend(app_config.get_models(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
-    except ImportError:
-        from django.db.models import get_model
-        return get_model(app_label, model_name)
-    else:
-        return apps.get_model(app_label, model_name)
-
-
-def get_models_for_app(app_label):
-    """Returns the models in the given app for an app label."""
-    try:
-        # django >= 1.7
-        from django.apps import apps
-    except ImportError:
-        from django.db.models import get_app, get_models
-        return get_models(get_app(app_label))
-    else:
-        return apps.get_app_config(app_label).get_models()
-
-
 def load_tag_library(libname):
     """Load a templatetag library on multiple Django versions.
 
@@ -197,46 +42,13 @@ def add_to_builtins_compat(name):
         engines['django'].engine.builtins.append(name)
 
 
-class ProxyParser(object):
-    """Faux parser object that will ferry our arguments into options."""
-
-    def __init__(self, command):
-        self.command = command
-
-    def add_argument(self, *args, **kwargs):
-        """Transform our argument into an option to append to self.option_list.
-
-        In argparse, "available specifiers [in help strings] include the
-        program name, %(prog)s and most keyword arguments to add_argument()".
-        However, optparse only mentions %default in the help string, and we
-        must alter the format to properly replace in optparse without error.
-        """
-        if 'help' in kwargs:
-            kwargs['help'] = kwargs['help'].replace('%(default)s', '%default')
-        self.command.option_list += (make_option(*args, **kwargs), )
-
-class CompatibilityBaseCommand(BaseCommand):
-    """Provides a compatibility between optparse and argparse transition.
-
-    Starting in Django 1.8, argparse is used. In Django 1.9, optparse support
-    will be removed.
-
-    For optparse, you append to the option_list class attribute.
-    For argparse, you must define add_arguments(self, parser).
-    BaseCommand uses the presence of option_list to decide what course to take.
-    """
-
-    def __init__(self, *args, **kwargs):
-        if django.VERSION < (1, 8) and hasattr(self, 'add_arguments'):
-            self.option_list = BaseCommand.option_list
-            parser = ProxyParser(self)
-            self.add_arguments(parser)
-        super(CompatibilityBaseCommand, self).__init__(*args, **kwargs)
-
-
-class CompatibilityAppCommand(AppCommand, CompatibilityBaseCommand):
-    """AppCommand is a BaseCommand sub-class without its own __init__."""
-
-
-class CompatibilityLabelCommand(LabelCommand, CompatibilityBaseCommand):
-    """LabelCommand is a BaseCommand sub-class without its own __init__."""
+def get_template_setting(template_key, default=None):
+    """ Read template settings pre and post django 1.8 """
+    templates_var = getattr(settings, 'TEMPLATES', None)
+    if templates_var is not None and template_key in templates_var[0]:
+        return templates_var[0][template_key]
+    if template_key == 'DIRS':
+        pre18_template_key = 'TEMPLATES_%s' % template_key
+        value = getattr(settings, pre18_template_key, default)
+        return value
+    return default
diff --git a/django_extensions/conf/app_template/forms.py.tmpl b/django_extensions/conf/app_template/forms.py.tmpl
index 6b477f9..c3927a7 100644
--- a/django_extensions/conf/app_template/forms.py.tmpl
+++ b/django_extensions/conf/app_template/forms.py.tmpl
@@ -1,3 +1,3 @@
 from django import forms
 
-# place form definition here
\ No newline at end of file
+# place form definition here
diff --git a/django_extensions/conf/app_template/urls.py.tmpl b/django_extensions/conf/app_template/urls.py.tmpl
index 96ef53f..5122b7b 100644
--- a/django_extensions/conf/app_template/urls.py.tmpl
+++ b/django_extensions/conf/app_template/urls.py.tmpl
@@ -1,6 +1,3 @@
-try:
-    from django.conf.urls import *
-except ImportError:  # django < 1.4
-    from django.conf.urls.defaults import *
+from django.conf.urls import include, url
 
 # place app url patterns here
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 26e8cde..b82b95d 100644
--- a/django_extensions/conf/command_template/management/commands/sample.py.tmpl
+++ b/django_extensions/conf/command_template/management/commands/sample.py.tmpl
@@ -4,5 +4,8 @@ from django.core.management.base import {{ base_command }}
 class Command({{ base_command }}):
     help = "My shiny new management command."
 
-    def {{ handle_method }}:
+    def add_arguments(self, parser):
+        parser.add_argument('sample', nargs='+')
+
+    def handle(self, *args, **options):
         raise NotImplementedError()
diff --git a/django_extensions/conf/template_tags_template/templatetags/sample.py.tmpl b/django_extensions/conf/template_tags_template/templatetags/sample.py.tmpl
index d0b4881..4bd3b15 100644
--- a/django_extensions/conf/template_tags_template/templatetags/sample.py.tmpl
+++ b/django_extensions/conf/template_tags_template/templatetags/sample.py.tmpl
@@ -1,4 +1,3 @@
 from django import template
 
 register = template.Library()
-
diff --git a/django_extensions/db/__init__.py b/django_extensions/db/__init__.py
index 9bad579..e69de29 100644
--- a/django_extensions/db/__init__.py
+++ b/django_extensions/db/__init__.py
@@ -1 +0,0 @@
-# coding=utf-8
diff --git a/django_extensions/db/fields/__init__.py b/django_extensions/db/fields/__init__.py
index 438f78c..0f71a10 100644
--- a/django_extensions/db/fields/__init__.py
+++ b/django_extensions/db/fields/__init__.py
@@ -1,4 +1,4 @@
-# coding=utf-8
+# -*- coding: utf-8 -*-
 """
 Django Extensions additional model fields
 """
@@ -21,20 +21,9 @@ except ImportError:
 
 from django.core.exceptions import ImproperlyConfigured
 from django.db.models import DateTimeField, CharField, SlugField
-from django.utils.crypto import get_random_string
 from django.template.defaultfilters import slugify
-
-try:
-    from django.utils.timezone import now as datetime_now
-    assert datetime_now
-except ImportError:
-    import datetime
-    datetime_now = datetime.datetime.now
-
-try:
-    from django.utils.encoding import force_unicode  # NOQA
-except ImportError:
-    from django.utils.encoding import force_text as force_unicode  # NOQA
+from django.utils.crypto import get_random_string
+from django.utils.encoding import force_text
 
 
 MAX_UNIQUE_QUERY_ATTEMPTS = 100
@@ -48,16 +37,10 @@ class UniqueFieldMixin(object):
 
     @staticmethod
     def _get_fields(model_cls):
-        if hasattr(model_cls._meta, 'get_fields'):
-            # verbosity due to replacement of deprecated model_cls._meta.get_fields_with_model(),
-            # as explained here: https://docs.djangoproject.com/en/1.9/ref/models/meta/#migrating-from-the-old-api
-            return [
-                (f, f.model if f.model != model_cls else None) for f in model_cls._meta.get_fields()
-                if not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)
-            ]
-        else:
-            # prior to 1.9
-            return model_cls._meta.get_fields_with_model()
+        return [
+            (f, f.model if f.model != model_cls else None) for f in model_cls._meta.get_fields()
+            if not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)
+        ]
 
     def get_queryset(self, model_cls, slug_field):
         for field, model in self._get_fields(model_cls):
@@ -185,33 +168,19 @@ class AutoSlugField(UniqueFieldMixin, SlugField):
         original_slug = slug
 
         if self.allow_duplicates:
+            setattr(model_instance, self.attname, slug)
             return slug
 
         return super(AutoSlugField, self).find_unique(
             model_instance, slug_field, self.slug_generator(original_slug, start))
 
     def pre_save(self, model_instance, add):
-        value = force_unicode(self.create_slug(model_instance, add))
+        value = force_text(self.create_slug(model_instance, add))
         return value
 
     def get_internal_type(self):
         return "SlugField"
 
-    def south_field_triple(self):
-        """Returns a suitable description of this field for South."""
-        # We'll just introspect the _actual_ field.
-        from south.modelsinspector import introspector
-        field_class = '%s.AutoSlugField' % self.__module__
-        args, kwargs = introspector(self)
-        kwargs.update({
-            'populate_from': repr(self._populate_from),
-            'separator': repr(self.separator),
-            'overwrite': repr(self.overwrite),
-            'allow_duplicates': repr(self.allow_duplicates),
-        })
-        # That's our definition!
-        return field_class, args, kwargs
-
     def deconstruct(self):
         name, path, args, kwargs = super(AutoSlugField, self).deconstruct()
         kwargs['populate_from'] = self._populate_from
@@ -322,24 +291,6 @@ class RandomCharField(UniqueFieldMixin, CharField):
     def internal_type(self):
         return "CharField"
 
-    def south_field_triple(self):
-        """Returns a suitable description of this field for South."""
-        # We'll just introspect the _actual_ field.
-        from south.modelsinspector import introspector
-        field_class = '%s.RandomCharField' % self.__module__
-        args, kwargs = introspector(self)
-        kwargs.update({
-            'lowercase': repr(self.lowercase),
-            'include_digits': repr(self.include_digits),
-            'include_aphla': repr(self.include_alpha),
-            'include_punctuation': repr(self.include_punctuation),
-            'length': repr(self.length),
-            'unique': repr(self.unique),
-        })
-        del kwargs['max_length']
-        # That's our definition!
-        return field_class, args, kwargs
-
     def deconstruct(self):
         name, path, args, kwargs = super(RandomCharField, self).deconstruct()
         kwargs['length'] = self.length
... 5376 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