GithubHelp home page GithubHelp logo

arteria / django-compat Goto Github PK

View Code? Open in Web Editor NEW
105.0 105.0 26.0 154 KB

Forward and backwards compatibility layer for Django 1.4, 1.7, 1.8, 1.9, 1.10, and 1.11

License: MIT License

Python 99.98% HTML 0.02%

django-compat's People

Contributors

brad avatar edwardbetts avatar eugena avatar flimm avatar geyser avatar jvamvas avatar lowks avatar moreati avatar philippeowagner avatar reduxionist avatar stylesen avatar thedrow avatar waffle-iron avatar walterrenner avatar yannik-ammann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-compat's Issues

New version brokes with Django==1.5.10 and six==1.3.0

   File "/var/www/.virtualenvs/ditchcity/local/lib/python2.7/site-packages/django/db/models/loading.py", line 72, in _populate
     self.load_app(app_name, True)
   File "/var/www/.virtualenvs/ditchcity/local/lib/python2.7/site-packages/django/db/models/loading.py", line 94, in load_app
     app_module = import_module(app_name)
   File "/var/www/.virtualenvs/ditchcity/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
     __import__(name)
   File "/var/www/.virtualenvs/ditchcity/local/lib/python2.7/site-packages/compat/__init__.py", line 42, in <module>
     from six.moves._thread import get_ident  # noqa
 ImportError: No module named _thread
ubuntu@staging:~$ python --version
Python 2.7.6

close_connection removed in 1.8

try:
    from django.db import close_old_connections as close_connection    
except ImportError:
    from django.db import close_connection # old Django version < 1.8

Private note:

  • django-cronium
  • django-background-tasks (see fork from kubic)

render_to_string - Django 1.8 changed how templates operate

FileNotFoundError: No such file or directory: README.rst

$ ./bin/pip --version
pip 8.0.2 from /webapps/planexo/lib/python3.4/site-packages (python 3.4)

$ ./bin/pip install django-compat
Collecting django-compat
  Using cached django-compat-1.0.8.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/tmp/pip-build-1wztbpt3/django-compat/setup.py", line 33, in <module>
        long_description=read('README.rst')
      File "/tmp/pip-build-1wztbpt3/django-compat/setup.py", line 17, in read
        return open(get_path(fname)).read()
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-build-1wztbpt3/django-compat/README.rst'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-1wztbpt3/django-compat/setup.py", line 36, in <module>
        long_description=read('README.md')
      File "/tmp/pip-build-1wztbpt3/django-compat/setup.py", line 17, in read
        return open(get_path(fname)).read()
      File "/webapps/planexo/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 8678: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1wztbpt3/django-compat

Warnings in setup.py

warning: no files found matching 'LICENSE'
warning: no files found matching 'README.rst'
warning: no files found matching 'README'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt

warning: check: missing required meta-data: url

warning: check: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied

WIP django monkey-patcher

Hello,

i'm planning a sprint at pyconfr to build a django compatibility module, which wouldn't behave like an intermediate module (like six for py3k, or like django-compat for django), but directly monkey-patch django with log-lifespan shims.

Thus, django webmaster who want to upgrade wouldn't have to fork/monkeypatch all their broken dependencies, and minor django upgrades would REALLY be minor (i.e would NOT rename/remove methods and attributes used by tons of unmaintained libs).

Would you be OK with integrating this monkey-patching utility to django-compat, to have an all-in-one solution, for BOTH library maintainers and library users ?

URLs include for Django 2.0

The next version of Django is changing quite radically the way URLs are being included, by requiring an app name to be provided. One way to do it (and sometimes the only one) is to change the first parameter to a tuple.

It would be great if there could be a version of include in django-compat. It looks like the new syntax is available from 1.9, and the old syntax is no longer working from 2.0.

Would that be an acceptable change? I could try to put together a PR if so.

get_query_set patching is very broken

The method included to patch get_query_set is very broken, and leads to some very bug code in circumstances where managers get subclassed - the behaviour of the subclass can be skipped. This is a very serious error for the case of Related managers, because it means that the limiting of the queryset that is added by the subclass get_query_set method gets skipped, so the related manager queries apply to all objects.

I've created a branch that demonstrates the problem, adding 4 tests, 2 of which fails with Django 1.8, one fails with Django 1.5:

https://github.com/spookylukey/django-compat/tree/get_query_set_patch_bug

I've created a PR so that you can see the tests failing.

The full details are explained in this blog post:

http://lukeplant.me.uk/blog/posts/handling-django's-get_query_set-rename-is-hard/

Support for Django 1.11 LTS

Django 1.11 LTS will be the last Django version to support Python 2. The next major release, Django 2.0, will only support Python 3.5+. So Django 1.11.x will probably be the last supported version for LTS-to-LTS support of django-compat (1.8-1.11). See Django's release notes for more.

ImportError: cannot import name 'LocaleRegexProvider' in Django 2.0a1

  File "/Users/Bruno/Documents/Workspace/open-source-projects/django-surveys/.tox/py36-djangomaster/lib/python3.6/site-packages/compat/__init__.py", line 388, in <module>
    from django.urls import (
ImportError: cannot import name 'LocaleRegexProvider'

From the updates in the tests in this PR, I'm under the impression that it was renamed to RegexPattern in Django 2.0a1.

Communicate supported Django version in README

These points should be better communicated in the README

  • what version of Django is supported and unsupported anymore
  • Version convention from django-compat to Django

Please note #17 as well that aims to show what works in wich version and if its tested.

Replace deprecated imp module with importlib

This project's tests uses the imp module which has been deprecated since Python 3.4 and set for removal in 3.12:

Python 3.12 is set for release on 2023-10-02 and this library is one of the top 5,000 most-downloaded from PyPI.

Please could you upgrade to use importlib? The imp docs have suggestions on what to use to replace each function and constant.

Adapt overview of supported compatible objects

Draft

compatible object 1.4 1.7 1.8 1.9 Notes/Documentation
ok ✔️ ✔️ ✔️
with issues ✔️ ⚠️ No solution found
broken

✔️ = compatible
⚠️ = basically compatible but has issues, eg. manual interactions, migration, ..
❌ = incompatible
✖️ = not supported by compat

django.contrib.contenttypes.generic is deprecated and will be removed

What should be added to compat? We currently use:

  • GenericForeignKey

Source: here

from django.contrib.contenttypes.admin import (  # NOQA isort:skip
    GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline,
)
from django.contrib.contenttypes.fields import (  # NOQA isort:skip
    GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.forms import (  # NOQA isort:skip
    BaseGenericInlineFormSet, generic_inlineformset_factory,
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.