You could use
```
if settings_dict.get('NAME') and len(settings_dict['NAME'])
```
if you wanted to prevent a KeyError too.

On Sunday, January 21, 2018 at 8:56:40 AM UTC+1, askpr...@gmail.com wrote:
>
> Hello !
>
> I have updated the PR as per Adam's review. However, I have not changed 
> L155 in backends/postgresql/base.py from 
>
> if settings_dict['NAME'] is not None
>
> to
>
> if 'NAME' in settings_dict
>
>
> *None may be used to connect to the default 'postgres' db. *
>
> *However, "if 'NAME' in settings_dict" prevents KeyError, but would still 
> return True if 'NAME' is assigned a 'NoneType'. *
>
> (Referred test_default_name method in tests/backends/base/test_creation.py)
>
> I tried testing Adam's suggestion on this, but it results in the following 
> error:
>
> TypeError: object of type 'NoneType' has no len()
>
> The PR is still open and needs review.
>
> Thanks and regards !
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/734ece8e-d543-47c0-b9d9-8dd2215df53e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to