Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#22618 closed Cleanup/optimization (fixed)

Documentation about import_string unclear

Reported by: Joachim Jablon Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I found about import_string and import_by_path from django.utils.module_loading, and read their doc :
https://docs.djangoproject.com/en/dev/ref/utils/#module-django.utils.module_loading

I have the feeling that the example is not chosen wisely as :

  • import_string raises an ImportError
  • but it replaces import_by_path that used to raise an ImproperlyConfigured error
  • And in the example, the function is used to load the ImproperlyConfigured class.

It may leave the fast reader or the beginner under the impression that this function returns an error when called with incorrect parameters. Or at least serious doubts.

(Additionaly, transition code could be provided but that's not as important)

Change History (3)

comment:1 by Tim Graham, 11 years ago

If we replaced the example with something like: ValidationError = import_string('django.core.exceptions.ValidationError') would that address your concerns?

comment:2 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In c501662f3c3f03876effcf3ede94922c0cec43bd:

Fixed #22618 -- Improved import_string example.

Thanks ewjoachim for the sugggestion.

comment:3 by Tim Graham <timograham@…>, 11 years ago

In 0bb90de869303f4e0fc9479391fde7c68b4088a0:

[1.7.x] Fixed #22618 -- Improved import_string example.

Thanks ewjoachim for the sugggestion.

Backport of c501662f3c from master

Note: See TracTickets for help on using tickets.
Back to Top