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

customdashboard command doesn't take arguments #1059

Open
fetzig opened this issue Nov 22, 2024 · 0 comments
Open

customdashboard command doesn't take arguments #1059

fetzig opened this issue Nov 22, 2024 · 0 comments

Comments

@fetzig
Copy link
Contributor

fetzig commented Nov 22, 2024

grappelli 3.0.9
django 4.2

According to docs one can add a custom filename/path as arg to the customdashboard command. But that arg doesn't work:

$ python manage.py customdashboard specialname.py
usage: manage.py customdashboard [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
manage.py customdashboard: error: unrecognized arguments: specialname.py

The implementation used in customdashboard.py is unknown to me:

class Command(BaseCommand):
    args = '[file]'

    def handle(self, file=None, **options):
        # ...

Fix would look like this:

class Command(BaseCommand):

    def add_arguments(self, parser):
        parser.add_argument(
            "path",
            nargs="?",  # Makes path argument optional
            type=str,
            default=None,
            help="Defines filepath",
        )

    def handle(self, *args, **options):
        local_path = options["path"]

Obviously one can use the command without args and just copy the file afterwards. Thus removing the extra examples from the docs would fix this as well.

Either way, happy to send a PR (target branch?). Let me know.

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