views:

306

answers:

4

Hi

i have a following solution structure in python:

main_app
main_app/template_processor/
main_app/template_processor/models
main_app/template_processor/views

everything works just fine on my local machine. as soon as code gets to server (it stopped working after i removed all .pyc files from svn), it doesn't see the assembly (if it could be called like that in terms of python) with models. during syncdb command, it creates no tables except for admin ones. but in runtime it finds models themselves, but does not find tables (since they were not created by syncdb)

i've added application to settings.py as installed app, everything seems to be fine. the only difference that i can see for now is that on my local machine i have main_app/template_processor/models/models.pyc file, but it doesn't precompile it on server for some reason (might be a hint??)

init.py files are existing in every folder/subfolder. have anyone faced an issue like that?

+1  A: 

Sounds like Django isn't seeing that module (folder, in this case) for some reason. Make sure all the folders have a file called init.py (notice the two underscores before and after, which you didn't mention in your post). Once that's done, make sure it's listed in your installed apps.

Maybe you made some change to it that's causing it to stop loading. You can also try moving the .pyc files out of the directory on your local machine and see whether they're regenerated or not when you runserver.

Maybe the most helpful thing: ./manage.py shell to bring up an interactive shell and then 'import app_name' (without quotes) to see whether django is having trouble finding the module.

John Debs
+1  A: 

Hm, looking at your directory structure, I think that you need to import all your models in template_processor/models/__init__.py, because Django looks only in <app_name>.models module when loading models automatically (i.e. for syncdb).

piranha
+1  A: 

My guess would be that you renamed a file, and didn't delete the oldname.pyc file.

So if you try to import oldname

then you rename oldname to rename, but don't update your import statement, the code will work on systems where oldname.pyc exists, however python won't be able to recreate oldname.pyc if oldname.py doesn't exist.

try

find . | grep py | xargs grep import | grep -v django | sort -u

that should give you a list of all imports in your project, see if one of those imports is pointing at a module for which you have a pyc file but not a .py file.

In general, python quickly compiles .py files into .pyc files, and it does this once. I wouldn't worry about the time it takes to generate new .pyc files.

paddy
A: 

Ok, if anyone's interested in what really was happening, i've got a story to tell ya: http://code.djangoproject.com/ticket/4470 that's basically what i was going to implement. in order to really get this thing work i still should have a file models.py, which will have a proper list of classess, with Pass inside of it. Then i should have taken all the files (my models) and changed their meta for syncdb to understand they are from the certain "assembly".

source code is available (pls see url above). thx for helping out!

ifesdjeen