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

Adding TrackerField to model makes django-extensions list_signals crash #512

Open
jlandercy opened this issue Dec 7, 2021 · 0 comments
Open

Comments

@jlandercy
Copy link

Problem

Dear JazzBand,

I just discovered this package and I was happy to find the TrackerField object which definitely brings a lot of value for cleaning and checking logics.

I have some CI quality flow running on my projects and unfortunately using this object in my model breaks this check from django-extensions:

python manage.py list_signals

With the following trace:

Traceback (most recent call last):
  File ".\project\manage.py", line 29, in <module>
    main()
  File ".\project\manage.py", line 25, in main
    execute_from_command_line(sys.argv)
  File ".\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File ".\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ".\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File ".\lib\site-packages\django\core\management\base.py", line 371, in execute
    output = self.handle(*args, **options)
  File ".\Python\Python39\site-packages\django_extensions-3.1.3-py3.9.egg\django_extensions\management\commands\list_signals.py", line 65, in han
dle
    verbose_name = force_str(key._meta.verbose_name)
AttributeError: 'str' object has no attribute '_meta'

I can see the problem occurs on the django-extensions package, so it might not be the right place to raise this issue.

Anyway, I was surprised to not need to migrate my schema once I have added the TrackerField so my first guess is that issue is somehow related with the fact that the TrackerField is not a full fledged field because it does not have any _meta registered.

I raise this issue to keep a track of it and gently raise your attention on it (maybe you have some useful input to add).
At this stage I am not sure if it is something missing at the TrackerField object or if the list_signals feature should be more careful on fields he wants to extract meta.

Once I have found a solution, I'll update this issue.
Feel free to add your observations.

Thank you anyway.

Environment

  • Django Model Utils version: django-model-utils==4.2.0
  • Django version: django==3.2.5
  • Python version: Python 3.9.7
  • Other libraries used, if any: django-extensions==3.1.3

Tested on several environments and OS.

Code examples

Add a simple tracker on a model:

# models.py
from django.db import models
from model_utils import FieldTracker

class Dummy(models.Model):
    # ...
    tracker = FieldTracker()

Run the list_signals on the project:

python manage.py list_signals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant