Opened 3 years ago
Closed 3 years ago
#33536 closed Bug (wontfix)
Running help() against django.db.models.PositiveIntegerField results in error
Reported by: | Brenden Hyde | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 4.0 |
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
Issue Description:
As a Django user, I would like to read built-in docstrings for Django classes without having an existing Django project.
When creating a new Django project, it can be helpful to read the built-in docstrings for each class in a package before beginning. For example, if I have never used django.db.models.PositiveIntegerField and want to know what the "null" or "blank" kwargs do, I can open a Python or IPython REPL and type the following:
from django.db import models help(models.PositiveIntegerField)
The above, in theory, should print the help doc for the PositiveIntegerField class. However, the current state of things causes a traceback instead:
ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
According to the Django docs, this issue is caused by not telling Django where your settings come from. However, if a user is just trying to read generic documentation for a given class, I don't think they should have to implement a concrete settings file first. Ideally, a user should be able to read these docs locally without creating anything at all. I realize that online documentation through the Django website is available, but it would be nice to be able to read the docstrings in a REPL.
Steps to Reproduce
- Create a new virtual environment (I use pipenv, but any should work)
- Install django~=4.0.0 and ipython to your virtualenv
- open the ipython REPL by running "ipython" from the command line
- In the REPL, run the following 2 lines of code:
from django.db import models help(models.PositiveIntegerField)
- The above should result in a traceback ending with this error message:
ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Change History (1)
comment:1 by , 3 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
Thanks for the feedback. This is caused by translatable class attributes like
description = _("Positive integer")
which access the setting. I don't see a feasible solution, but these classes don't have docstrings anyway.