Hi, Johan,
To answer the spirit of your question: Mostly, you will get the correct import locations from the examples you use. Once you're used to Python, you will see that there is a logic to the imports:
* You start at wherever your virtualenv stores its site-packages if you use virtualenv, otherwise it should be somewhere in your Python path. For example, my virtualenv directory is called ve, so I start at ve/lib/python2.7/site-packages.
* Next you just burrow down the path, keeping in mind the convention that a python module that you can import from is either a file with the module name, or a directory with the module name, that has an __init__.py file in it. For example: The import source above could be in ve/lib/python2.7/site-packages/django/http.py or in ve/lib/python2.7/site-packages/django/http/__init__.py. In our case, the second one is the right one.
* Note that when you open up that file, you see that it actually imports the HttpResponse from django.http.response, which sits in the same directory in the response.py file. This is usually due to a few factors: Backwards compatibility, more compact imports of related functionality from elsewhere, or maybe it's just the preferred coding style :)
OK, so that covers django imports, as well as other specific packages in your requirements files, if you use pip (and you should, really). There are 2 other non-obvious places you will have imports:
1. If you have installed extra python packages globally, you might be able to import those from other locations in the path. There, you probably need to open a python debugger and look at sys.path to see where to start looking for the actual files.
2. Python has many, many modules included, but not imported by default. These you will encounter as you search for examples on how to do things in Python. For example, math:
>>> from math import sqrt
>>> sqrt(16)
4
That should cover it. Keep in mind that Python is open source, so you can find most of this from reading the source code. However, it's all documented pretty well on the Django site, as well as various Python docs sites.
Hope this helps,
Johan