#31098 closed Bug (invalid)
has_add_permission() takes 2 positional arguments but 3 were given.
Reported by: | Mihai Zamfir | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 3.0 |
Severity: | Normal | Keywords: | admin inlines permission |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In n class inheriting from ModelAdmin, I'm doing
def get_inline_instances(self, request, obj=None): inline_instances = super().get_inline_instances(request, obj) ...
and the super call is throwing an error in the source code of Django here:
def get_inline_instances(self, request, obj=None): inline_instances = [] for inline_class in self.get_inlines(request, obj): inline = inline_class(self.model, self.admin_site) if request: if not (inline.has_view_or_change_permission(request, obj) or inline.has_add_permission(request, obj) or # AT THIS LINE inline.has_delete_permission(request, obj)): continue if not inline.has_add_permission(request, obj): inline.max_num = 0 inline_instances.append(inline) return inline_instances
Haven't had this problem with Django 2.0
Change History (6)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Summary: | has_add_permission() takes 2 positional arguments but 3 were given → has_add_permission() takes 2 positional arguments but 3 were given. |
Support for InlineModelAdmin.has_add_permission()
methods that don’t accept obj
as the second positional argument was deprecated in Django 2.1 and removed in Django 3.0.
We had a small regression in Django 2.1.0 (see #29723), so you should use Django 2.1.1+.
follow-up: 6 comment:5 by , 5 years ago
Thanks for the response. However, that's not something I can control. As in the snippet above, I'm just calling the parent method, the super call errors.
def get_inline_instances(self, request, obj=None): inline_instances = super().get_inline_instances(request, obj)
comment:6 by , 5 years ago
Replying to Mihai Zamfir:
Thanks for the response. However, that's not something I can control. As in the snippet above, I'm just calling the parent method, the super call errors.
def get_inline_instances(self, request, obj=None): inline_instances = super().get_inline_instances(request, obj)
Of course you can, your class that inherits from ModelAdmin
has inlines with a custom has_add_permission()
method that doesn't accept obj
argument. Please use one of support channels.
This sounds like a duplicate of #29723. Which version of Django do you have installed exactly?
Could you share the entire code of your
ModelAdmin
definition?Thanks.