Bill Freeman wrote:
> If that wasn't a typo, I suspect that you're going to have trouble
> with having a directory
> named "views.py".  
yes it was a typo... my dir is called 'views'
> I don't know how you import anything from it unless
> it is directly on
> your path.
>
> When you say "my app is in the pythonpath of the environment":
>    1. Which directory is in the python path?
>   
my pythonpath is called 'site-packages' and this one is in the
pythonpath. every packages in there has an __init__.py in each subdir.
>    2. If you mean that you've added it to the PYTHONPATH environment
> variable then
> please check whether you can find it in sys.path when running in the manage.py
> shell.  (If you don't know how to do that, please ask.)  I don't know
> if your on Windows
> or something else, but, especially on Windows, I don't take it for
> granted that environment
> settings will be properly respected/available.
>   
im on a unix system and i can import it on the django shell but it makes
troubles when running the django server which doesnt make sense
> Bill
>
> On Thu, Nov 12, 2009 at 2:39 AM, andreas schmid <a.schmi...@gmail.com> wrote:
>   
>> Bill Freeman wrote:
>>     
>>> Does your project root (I'm assuming that's the directory containing
>>> the sub directory "app") have an __init__.py file.  Does the app
>>> directory?  I'm assuming that the one you mention below is in
>>> app/models/ .  All three are required, if what you have on your
>>> sys.path is just the project root.
>>>
>>>
>>>       
>> my app is in the pythonpath of the environment and every directory has
>> an __init__.py
>> everything worked fine till i changed the structure from:
>>
>> app/
>>    __init__.py
>>    models.py
>>    views.py
>>    urls.py
>>
>> to:
>>
>> app/
>>    models/
>>             __init__.py
>>             models.py
>>    views.py/
>>             __init__.py
>>             whatever.py
>>             another.py
>>    urls/
>>             __init__.py
>>             myurls.py
>>             anotherurls.py
>> __init__.py
>>
>> so it doesnt really make sense that i cant import something in the
>> second case from my point of view.
>>
>>
>>     
>>> Do make sure that your project root is on your sys.path.  You can do
>>> that by temporarily adding:
>>>
>>>     import foo
>>>
>>> to settings.py, and creating a file foo.py in the project root containing, 
>>> say:
>>>
>>>     print "Foo!"
>>>
>>> and then do:
>>>
>>>     python manage.py shell
>>>
>>> As part of the startup printout you should get a line containing only:
>>>
>>>     Foo!
>>>
>>> By the way, I'm pretty sure that lots of django internal machinery,
>>> like syncdb, for example, depends on there being a file named exactly
>>> "models.py" in each app.  So a better choice of directory structure
>>> might be "app/myapp/models.py", with your myclass class in the
>>> models.py file.  Pinax uses such a structure, though the upper
>>> directory is called apps instead of app (there may be more than one)
>>> and has been added to the path, so that you can mention it in
>>> INSTALLED_APPS as just 'myapp', rather than 'apps/myapp'.  If you go
>>> this route, you will want to insert the apps directory at or near the
>>> beginning of sys.path, rather than appending it, so that when you
>>> mention a possibly installed app, such as django_microblogging, but
>>> which you have customized in a copy in your apps folder, you can say
>>> 'microblogging' in your INSTALLED_APPS and it will find yours rather
>>> than the system version.  (TN.B.: emplate paths are a separate issue.)
>>>
>>> Bill
>>>
>>> On Wed, Nov 11, 2009 at 10:34 AM, andreas schmid <a.schmi...@gmail.com> 
>>> wrote:
>>>
>>>       
>>>> im experiencing the same problem.
>>>> i started with a simple app and the modules.py was at the root of the
>>>> app package, so everything was fine.
>>>> now i extended the app and restructured the files in it by making a
>>>> subfolder app/models and inside an __init__.py and the mymodel.py
>>>>
>>>> in the urls.py which i have an import like
>>>> from app.models.mymodel import myclass
>>>>
>>>> and while the django shell is able to import it without any problem the
>>>> django server isnt. im using buildout to build the whole django
>>>> environment so the python interpreter im starting the shell and the one
>>>> of the server is the same.
>>>>
>>>> i already tried to remove all .pyc and start everything again but i had
>>>> no luck.
>>>>
>>>> this is weird and i cant figure out what the problem could be.
>>>>
>>>>
>>>>
>>>> Bill Freeman wrote:
>>>>
>>>>         
>>>>> I had another couple of thoughts.
>>>>>
>>>>> In the manage.py shell, try:
>>>>>
>>>>>     from openid.yadis import xri
>>>>>     xri
>>>>>
>>>>> The output will include from where it got xri.  Make sure that it's
>>>>> coming from your lib directory, and not from some old system wide
>>>>> installation of openid.
>>>>>
>>>>>
>>>>> Instead of:
>>>>>
>>>>>     from openid.association import Association as OIDAssociation
>>>>>
>>>>> try:
>>>>>
>>>>>     from association import Association as OIDAssociation
>>>>>
>>>>>
>>>>> Also, expecially if the previous worked, in your settings.py, instead of:
>>>>>
>>>>>     sys.path.append(os.path.join(FILE_ROOT, 'lib', 'openid'))
>>>>>
>>>>> try
>>>>>
>>>>>     sys.path.append(os.path.join(FILE_ROOT, 'lib'))
>>>>>
>>>>> Bill
>>>>>
>>>>>
>>>>>
>>>>>           
>>> --~--~---------~--~----~------------~-------~--~----~
>>> 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-us...@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=.
>>
>>
>>
>>     
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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=.
>
>
>
>   

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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=.


Reply via email to