django-adminactions icon indicating copy to clipboard operation
django-adminactions copied to clipboard

Very lame fix for #199

Open timthelion opened this issue 4 years ago • 4 comments

timthelion avatar Dec 06 '21 21:12 timthelion

Unfortunately, though this fix works locally for me, on the server it's failing.

System check identified some issues:

WARNINGS:
<bunch of we broke backwards compatibility in Django4 because we hate you warnings>
Operations to perform:
  Apply all migrations: aklub
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
Traceback (most recent call last):
  File "manage.py", line 26, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 267, in handle
    emit_post_migrate_signal(
  File "/usr/local/lib/python3.8/site-packages/django/core/management/sql.py", line 48, in emit_post_migrate_signal
    models.signals.post_migrate.send(
  File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 177, in send
    return [
  File "/usr/local/lib/python3.8/site-packages/django/dispatch/dispatcher.py", line 178, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/home/aplikace/src/django-adminactions/src/adminactions/models.py", line 9, in create_extra_permissions_handler
    p.create_extra_permissions()
  File "/home/aplikace/src/django-adminactions/src/adminactions/perms.py", line 34, in create_extra_permissions
    content_types = ContentType.objects.get_for_models(*models)
  File "/usr/local/lib/python3.8/site-packages/django/contrib/contenttypes/models.py", line 89, in get_for_models
    opts_models = needed_opts.pop(ct.model_class()._meta, [])
AttributeError: 'NoneType' object has no attribute '_meta'

Seems to me, that we simply cannot rely on content types working in post migrate signals because we don't know if they've been set up yet :(

timthelion avatar Dec 20 '21 10:12 timthelion

Codecov Report

Merging #200 (0d744c9) into develop (93a661f) will increase coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #200      +/-   ##
===========================================
+ Coverage    84.84%   84.85%   +0.01%     
===========================================
  Files           23       23              
  Lines         1260     1261       +1     
  Branches       236      257      +21     
===========================================
+ Hits          1069     1070       +1     
  Misses         130      130              
  Partials        61       61              
Impacted Files Coverage Δ
src/adminactions/perms.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 93a661f...0d744c9. Read the comment docs.

codecov[bot] avatar Dec 20 '21 10:12 codecov[bot]

Seems that python3 manage.py remove_stale_contenttypes cleared up that issue so this is probably good to go.

timthelion avatar Dec 20 '21 20:12 timthelion

Wait, why did you close this? That command doesn't fix #200 , it just fixes the problem with this commit ;)

timthelion avatar Dec 20 '21 20:12 timthelion