Skip to content

Commit

Permalink
__path__ is a better choice than __file__.
Browse files Browse the repository at this point in the history
  • Loading branch information
mblayman committed Apr 9, 2022
1 parent 645673c commit 729aec7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion django_extensions/management/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def find_job_module(app_name: str, when: Optional[str] = None) -> str:
parts.append(when)
module_name = ".".join(parts)
module = importlib.import_module(module_name)
return os.path.dirname(module.__file__)
return module.__path__[0]


def import_job(app_name, name, when=None):
Expand Down

1 comment on commit 729aec7

@jiansongyang
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if there happens to be a file (not a module) named "jobs" in an app's root directory? Django-rq is an example. By doing this you are closing the door to apps doing this way. I have to down grade to v3.1.5 given that django-rq is part of my product.

Please sign in to comment.