On 6 août, 03:04, Adam Zedan <hayya...@gmail.com> wrote: > Hi while going through the Django Book I ran into the following code > Being fairly new to Python the code kind of confused me
Python-related questions ought to posted on comp.lang.python... But anyway: > from django.db import models --->lineA > class Publisher(models.Model): --->line B > > Consider line A > from django.db import models > This means that in the django directory therewill be a subdirectory of > db from in which either you'll find a file called models.py or a > directory called models??Rite?? This means: import the object named 'models' (whatever it happens to be) from the module or package named "django.db" and bound it to the name "models" in the current namespace. In this case, "django.db.models" happens to be a package (technically, a directory containing an __init__.py file). > > Moving on to Line B > class Publisher(models.Model): > i am more interested in the models.Model. > does that mean in the models folder youll find a Model.py ?? No. That means that there's something (actually a class object) bound to the name "Model" in the django.db.models package's namespace. > I cant > seem to find Model.py then?? could anyone please clear this > concept..why cant i find this file ?? I would like to take a look at > the base class models.Model. Read the django/db/models/__init__.py file and you'll find out that the Model base class is defined in django/db/models/base.py. > I have checked a couple of sites on python tutorial and they dont > cover imports in that much detail.... You obviously forgot to start with the official tutorial. This is covered in "modules and packages" part: http://docs.python.org/tutorial/modules.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.