#33536: Running help() against django.db.models.PositiveIntegerField results in
error
-----------------------------------------+------------------------
               Reporter:  Brenden Hyde   |          Owner:  nobody
                   Type:  Bug            |         Status:  new
              Component:  Uncategorized  |        Version:  4.0
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 **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
 [https://docs.djangoproject.com/en/4.0/topics/settings/#envvar-
 DJANGO_SETTINGS_MODULE/ 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**
 1. Create a new virtual environment (I use pipenv, but any should work)
 2. Install django~=4.0.0 and ipython to your virtualenv
 3. open the ipython REPL by running "ipython" from the command line
 4. In the REPL, run the following 2 lines of code:

 {{{
 from django.db import models
 help(models.PositiveIntegerField)
 }}}
 5. 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.
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33536>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.427ac490e032bc461d49861a0d509f65%40djangoproject.com.

Reply via email to