I think if you should read http://docs.python.org/tutorial/modules.html, specially packages part

On 07/08/11 21:51, Hayyan Rafiq wrote:

Got it working just inserted a init.py file init. so it got recognized as a python directory
------------------------------------------------------------------------
From: hayya...@hotmail.com
To: django-users@googlegroups.com
Subject: RE: Why isnt this simple import working??
Date: Sun, 7 Aug 2011 19:48:03 +0000

I think i know why this isnt working becuase the form folder does not have an init.py init.py init. So my qustion is how do u import a class from a python file in a random folder?

------------------------------------------------------------------------
From: hayya...@hotmail.com
To: django-users@googlegroups.com
Subject: Why isnt this simple import working??
Date: Sun, 7 Aug 2011 19:35:30 +0000

While trying to construct an example from the django book chapter7.

I used the following import code in my views.py

*from mysite.form.forms import ContactForm*
now ContactForm is a class in forms.py located in "D:\Django-1.3\django\bin\mysite\form"
where mysite=dir
form=dir
forms= python file
ContactForm =Class

Ultimately i get this error


  ImportError at /contact

No module named form.forms
Request Method:         GET
Request URL:    http://127.0.0.1:8000/contact
Django Version:         1.3
Exception Type:         ImportError
Exception Value:        
No module named form.forms
Exception Location: D:\Django-1.3\django\bin\mysite\views.py in <module>, line 4
Python Executable:      D:\Python27\python.exe
Python Version:         2.7.2
Python Path:    
['D:\\Django-1.3\\django\\bin\\mysite',
  'D:\\Python27\\Lib\\site-packages',
  '*D:\\Django-1.3\\django\\bin*',
  'C:\\WINDOWS\\system32\\python27.zip',
  'D:\\Python27\\DLLs',
  'D:\\Python27\\lib',
  'D:\\Python27\\lib\\plat-win',
  'D:\\Python27\\lib\\lib-tk',
  'D:\\Python27']






--
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.

--
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.
--
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.

--
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.

Reply via email to