Skip to content

Intro Compat for Nu Django versions #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This version is merely a fixx to create compatibility with nu versions of Django (starting with Django==1.11.11)
---

# django-singleton

Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from setuptools import setup, find_packages

setup(name='django-singleton',
version='0.1.9',
description='Reusable singleton models for Django',
author='Chris Davis',
author_email='defbyte@gmail.com',
url='https://github.com/defbyte/django-singleton',
version='0.2.0',
description='Reusable singleton models for Django (originally by Chris Davis)',
author='Nemesis Fixx',
author_email='joewillrich@gmail.com',
url='https://github.com/NuChwezi/django-singleton',
packages=find_packages(),
include_package_data=True,
zip_safe=False,
Expand All @@ -20,4 +20,4 @@
'Programming Language :: Python',
'Framework :: Django',
]
)
)
12 changes: 6 additions & 6 deletions singleton_models/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin
from django.utils.translation import ugettext as _
from django.utils.encoding import force_unicode
from . compat import force_unicode
from django.http import HttpResponseRedirect
from functools import update_wrapper

Expand All @@ -21,16 +21,16 @@ def get_urls(self):
try:
from django.conf.urls.defaults import patterns, url
except ImportError:
from django.conf.urls import patterns, url
from django.conf.urls import url

def wrap(view):
def wrapper(*args, **kwargs):
return self.admin_site.admin_view(view)(*args, **kwargs)
return update_wrapper(wrapper, view)

info = self.model._meta.app_label, self.model._meta.module_name
info = self.model._meta.app_label, self.model._meta.model_name

urlpatterns = patterns('',
urlpatterns = [
url(r'^history/$',
wrap(self.history_view),
{'object_id': '1'},
Expand All @@ -39,7 +39,7 @@ def wrapper(*args, **kwargs):
wrap(self.change_view),
{'object_id': '1'},
name='%s_%s_changelist' % info),
)
]
return urlpatterns

def response_change(self, request, obj):
Expand All @@ -49,7 +49,7 @@ def response_change(self, request, obj):
opts = obj._meta

msg = _('%(obj)s was changed successfully.') % {'obj': force_unicode(obj)}
if request.POST.has_key("_continue"):
if "_continue" in request.POST:
self.message_user(request, msg + ' ' + _("You may edit it again below."))
return HttpResponseRedirect(request.path)
else:
Expand Down
9 changes: 9 additions & 0 deletions singleton_models/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.utils import encoding

# ugly hack required for Python 2/3 compat
if hasattr(encoding, 'force_unicode'):
force_unicode = encoding.force_unicode
elif hasattr(encoding, 'force_text'):
force_unicode = encoding.force_text
else:
force_unicode = lambda x: x