Skip to content
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

Upgrade to Django 1.9 (backward compatible) #30

Open
wants to merge 4 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: 1 addition & 1 deletion django_settings/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_setting_model(self, obj, request):
if obj:
return obj.setting_object.__class__
try:
typename = request.REQUEST['typename'] # NOTE: both lines might
typename = request.GET['typename'] # NOTE: both lines might
return dataapi.data.model_for_name(typename) # raise KeyError
except KeyError:
raise Http404
Expand Down
14 changes: 10 additions & 4 deletions django_settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
# framework
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
try:
from django.contrib.contenttypes.fields import GenericForeignKey
except:
from django.contrib.contenttypes.generic import GenericForeignKey
from django.utils.translation import ugettext_lazy as _
from django.dispatch import receiver
from django.db.models.signals import post_syncdb
try:
from django.db.models.signals import post_migrate
except:
from django.db.models.signals import post_syncdb as post_migrate

from .moduleregistry import new_registry

Expand Down Expand Up @@ -61,7 +67,7 @@ class Meta:

setting_type = models.ForeignKey(ContentType)
setting_id = models.PositiveIntegerField()
setting_object = generic.GenericForeignKey('setting_type', 'setting_id')
setting_object = GenericForeignKey('setting_type', 'setting_id')

name = models.CharField(max_length=255, unique=conf.DJANGO_SETTINGS_UNIQUE_NAMES)

Expand Down Expand Up @@ -111,7 +117,7 @@ class Meta:
# end ###################


@receiver(post_syncdb)
@receiver(post_migrate)
def handle_post_syncdb(sender, **kwargs):
from django_settings.dataapi import initialize_data
initialize_data()
6 changes: 5 additions & 1 deletion django_settings/templatetags/settings_admin_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
@register.filter
def add_url_for_setting_type(admin_change_list, type_name):
cl = admin_change_list
url_name = 'admin:%s_%s_%s' % (cl.opts.app_label, cl.opts.module_name, 'add')
try:
model_name = cl.opts.model_name
except AttributeError:
model_name = cl.opts.module_name
url_name = 'admin:%s_%s_%s' % (cl.opts.app_label, model_name, 'add')
query = "typename=%(type)s%(popup)s" % dict(
type=type_name,
popup='_popup=1' if cl.is_popup else '',
Expand Down