0

I'm trying to hook-up lamson with django 1.4. I've seen the documentation on hooking up lamson with django and the librelist example from the source, but it seems to use a previous version of django.

I have created a "webapp" project that contains an "emails" app as described in the basic django 1.4 tutorial.

The webapp/webapp/settings.py file contains a reference to the emails application in the installed_apps like this:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'emails',
)

The lamson application folder contains the webapp folder for the django project. Now, instead of having a "webapp/emails" folder that contains everything like in the librelist example provided by Zed Shaw, i have yet another webapp folder that contains the settings.py, plus the extra application folder (emails) that contains the models and all (this is due to the new directory structure in django 1.4).

In the config/settings.py file for lamson, I have added the following line:

os.environ['DJANGO_SETTINGS_MODULE'] = 'webapp.webapp.settings'

Now, in the my handler code, (app/handlers/my_handler.py), i have imported my models:

import webapp.emails.models

I can create instances from my model correctly, but as soon as i try to save them to the database using my_instance.save(), I get the following error:

File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
ImportError: No module named emails

Any idea what the problem can be?

Otherwise, is it possible to remove django 1.4 and use django 1.3 to make it work?

Thanks for your help

user19304
  • 55
  • 4

1 Answers1

0

This is setup which worked for me

move webapp and mailserver folders on the same level

mailserver #lamson project
- lamson files
webapp #django 1.4 app
- settings.py ...

In lamson settings.py

import sys
import os
sys.path.append('../webapp')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

now you can access django project modules in lamson handler without any prefix

e.g.

import emails.models
romanlv
  • 1,432
  • 15
  • 15
  • Thanks for that answer! I haven't tried it yet though...I downgraded to django 1.3 and configuration like in the librelist example worked just fine. I'll try your solution as soon as possible. Thanks! P.S: I have another lamson question if you want some more points :p – user19304 Jun 21 '12 at 14:58
  • Here is the [link](http://stackoverflow.com/questions/11141122/lamson-mail-address-format) to the question, just in case: – user19304 Jun 21 '12 at 15:09