Wednesday, December 28, 2016¶
I continued to work for #1285, but did not yet commit. Details later.
As I work through the tutorials, I like to see with my own eyes the module and class/attribute that I am inheriting from calling or assigning. However, I went to the right place, but the files seem to be missing. For example, in Django tutorial Part 1:from django.conf.urls import include urls
So I go to Github django code and I find:
What I find is that urls is a directory with only files :
static.py. There is no urls.py file which might have url() or include() methods.
models.Models. I see some code line
from django.db import modelsand on django Github site I navigate until django/django/db/models. I see that
modelsis a directory, not a file with a class
So, what am I missing here?
What you are missing is related to packages. Admittedly the corresponding doc section is not very clear about your problem. I make a summary:
A package is a module which can contain submodules
A package consists of a directory containing a file
__init__.pyand optinally other .py files (which are then submodules of that package).
Everything defined in the
__init__.pyfile is considered part of the package.
This last point is important in your case. When using
import item, the
item can be either a submodule (or
subpackage) of the package, or some other name defined in the
Rule of thumb : when you want to see the code which defines a.b.c,
then it can be either in a file
a/b/c.py or in a file