#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 , 11 years ago
comment:2 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
If we replaced the example with something like:
ValidationError = import_string('django.core.exceptions.ValidationError')
would that address your concerns?