﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34020	django core management error	brian-methodical	nobody	"When running custom admin management command getting unexpected error ""

'NoneType' object has no attribute 'endswith'


Here is the stack-trace:


``` 

{{{
Traceback (most recent call last):
  File ""/Users/brianray/GitHub/methodical-feature-space/fserve/./manage.py"", line 21, in <module>
    main()
  File ""/Users/brianray/GitHub/methodical-feature-space/fserve/./manage.py"", line 17, in main
    execute_from_command_line(sys.argv)
  File ""/opt/anaconda3/lib/python3.9/site-packages/django/core/management/__init__.py"", line 446, in execute_from_command_line
    utility.execute()
  File ""/opt/anaconda3/lib/python3.9/site-packages/django/core/management/__init__.py"", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/opt/anaconda3/lib/python3.9/site-packages/django/core/management/base.py"", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File ""/opt/anaconda3/lib/python3.9/site-packages/django/core/management/base.py"", line 460, in execute
    output = self.handle(*args, **options)
  File ""/Users/brianray/GitHub/methodical-feature-space/fserve/ftasks/management/commands/dumpurls.py"", line 15, in handle
    self.stdout.write(pprint.pprint(urls))
  File ""/opt/anaconda3/lib/python3.9/site-packages/django/core/management/base.py"", line 169, in write
    if ending and not msg.endswith(ending):
AttributeError: 'NoneType' object has no attribute 'endswith'

}}}

```

To reproduce take this code:

```

{{{

from django.core.management.base import BaseCommand
from django.urls import get_resolver
import pprint

class Command(BaseCommand):
    help = 'dumps all the endpoint urls'


    def handle(self, *args, **options):
        urls = {pat.name: str(pat.pattern._route) for pat in get_resolver().url_patterns 
                if getattr(pat, ""name"", None)}

        self.stdout.write(self.style.SUCCESS('Here are the urls: \n\n'))

        self.stdout.write(pprint.pprint(urls))
        self.stdout.write(""\n"")
        return True

}}}

```

put into {BASE}/{module}/management/commands ...

Django==4.0.5"	Uncategorized	closed	Uncategorized	4.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
