diff options
author | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
---|---|---|
committer | Arthur Koziel <arthur@arthurkoziel.com> | 2010-09-13 00:04:27 +0000 |
commit | dd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch) | |
tree | 326dd25bb045ac016cda7966b43cbdfe1f67d699 /django/contrib/admin/options.py | |
parent | c9b188c4ec939abbe48dae5a371276742e64b6b8 (diff) | |
download | django-soc2010/app-loading.tar.gz |
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/contrib/admin/options.py')
-rw-r--r-- | django/contrib/admin/options.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index abbe14c948..ffa3a533e9 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -108,7 +108,13 @@ class BaseModelAdmin(object): # rendered output. formfield can be None if it came from a # OneToOneField with parent_link=True or a M2M intermediary. if formfield and db_field.name not in self.raw_id_fields: - formfield.widget = widgets.RelatedFieldWidgetWrapper(formfield.widget, db_field.rel, self.admin_site) + related_modeladmin = self.admin_site._registry.get( + db_field.rel.to) + can_add_related = bool(related_modeladmin and + related_modeladmin.has_add_permission(request)) + formfield.widget = widgets.RelatedFieldWidgetWrapper( + formfield.widget, db_field.rel, self.admin_site, + can_add_related=can_add_related) return formfield @@ -502,7 +508,7 @@ class ModelAdmin(BaseModelAdmin): # Convert the actions into a SortedDict keyed by name # and sorted by description. - actions.sort(lambda a,b: cmp(a[2].lower(), b[2].lower())) + actions.sort(key=lambda k: k[2].lower()) actions = SortedDict([ (name, (func, name, desc)) for func, name, desc in actions @@ -755,7 +761,7 @@ class ModelAdmin(BaseModelAdmin): if isinstance(response, HttpResponse): return response else: - return HttpResponseRedirect(".") + return HttpResponseRedirect(request.get_full_path()) else: msg = _("No action selected.") self.message_user(request, msg) |