-
Notifications
You must be signed in to change notification settings - Fork 297
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What version of Unfold are you using?
0.64.2
What version of Django are you using?
4.2.7
What browser are you using?
Not relevant
Did you checked changelog/commit history, if the bug is not already fixed?
Yes
Did you searched other issues, if the bug is not already fixed?
Yes
Did you checked documentation?
Yes
Are you able to replicate the bug in the demo site?
No, bug requires to run manage.py migrate
with an empty database
Repository with reproduced bug
Describe your issue
As long as you have an action using a global permission, for example:
@action(
permissions=["accounts.change_user"],
)
def anonymize_user(self, request, object_id, *args, **kwargs):
user = get_object_or_404(User, pk=object_id)
When you run manage.py migrate
with an empty database, it fails while checking for the permissions to exists because the permissions table doesn’t exist in the database:
Traceback (most recent call last):
File "/srv/app/./manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "/home/snake/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/home/snake/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/snake/.local/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/snake/.local/lib/python3.9/site-packages/django/core/management/base.py", line 453, in execute
self.check()
File "/home/snake/.local/lib/python3.9/site-packages/django/core/management/base.py", line 485, in check
all_issues = checks.run_checks(
File "/home/snake/.local/lib/python3.9/site-packages/django/core/checks/registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/snake/.local/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 51, in check_admin_app
errors.extend(site.check(app_configs))
File "/home/snake/.local/lib/python3.9/site-packages/django/contrib/admin/sites.py", line 97, in check
errors.extend(modeladmin.check())
File "/home/snake/.local/lib/python3.9/site-packages/django/contrib/admin/options.py", line 139, in check
return self.checks_class().check(self, **kwargs)
File "/home/snake/.local/lib/python3.9/site-packages/unfold/checks.py", line 15, in check
*self._check_unfold_action_permission_methods(admin_obj),
File "/home/snake/.local/lib/python3.9/site-packages/unfold/checks.py", line 39, in _check_unfold_action_permission_methods
if not Permission.objects.filter(
File "/home/snake/.local/lib/python3.9/site-packages/django/db/models/query.py", line 1241, in exists
return self.query.has_results(using=self.db)
File "/home/snake/.local/lib/python3.9/site-packages/django/db/models/sql/query.py", line 598, in has_results
return compiler.has_results()
File "/home/snake/.local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1530, in has_results
return bool(self.execute_sql(SINGLE))
File "/home/snake/.local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
cursor.execute(sql, params)
File "/home/snake/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/home/snake/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/snake/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
File "/home/snake/.local/lib/python3.9/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/snake/.local/lib/python3.9/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "auth_permission" does not exist
LINE 1: SELECT 1 AS "a" FROM "auth_permission" INNER JOIN "django_co...
^
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working