tags:

views:

24

answers:

1

I am trying to get the form preview django module example to work. In polls_app/mysite/urls.py:

from django.conf.urls.defaults import *
from mysite.preview import SomeModelFormPreview
from mysite.forms import SomeModelForm
from django import forms

In polls_app/mysite/SomeModelFormPreview.py:

from django.contrib.formtools.preview
import FormPreview from mysite.models
import SomeModel

class SomeModelFormPreview (FormPreview):
    def done(self,request,cleaned_data):
        return HttpResponseRedirect("/form/success")

I am following the example here: http://docs.djangoproject.com/en/1.2/ref/contrib/formtools/form-preview/#module-django.contrib.formtools

This is the import error I receive:

ImportError at / No module named preview Request
Method:    GET
Request URL:    http://127.0.0.1:8000/
Django Version:    1.2.1
Exception Type:    ImportError
Exception Value:     No module named preview
Exception Location:    /home/adam/Desktop/polls_app/mysite/../mysite/urls.py in <module>, line 4 Python
Executable:    /usr/bin/python Python
Version:    2.6.2 Python
Path:    ['/home/adam/Desktop/polls_app/mysite',
            '/usr/lib/python2.6',
            '/usr/lib/python2.6/plat-linux2',
            '/usr/lib/python2.6/lib-tk',
            '/usr/lib/python2.6/lib-old',
            '/usr/lib/python2.6/lib-dynload',
            '/usr/lib/python2.6/dist-packages',
            '/usr/lib/python2.6/dist-packages/PIL',
            '/usr/lib/python2.6/dist-packages/gst-0.10',
            '/var/lib/python-support/python2.6',
            '/usr/lib/python2.6/dist-packages/gtk-2.0',
            '/var/lib/python-support/python2.6/gtk-2.0',
            '/usr/local/lib/python2.6/dist-packages']
Server time:    Mon, 12 Jul 2010 11:16:13 -0500
A: 

It would appear that mysite.preview does not exist. That is the error you're seeing. This may be the result of circular includes, or an incorrect name.

Jack M.
adam@adam-desktop:~/Desktop/polls_app/mysiteThat is where SomeModelFormPreview.py and urls.py is located. I'm not sure if it makes a difference.
atomical
@atomical according to your code SomeModelFormPreview should be in the preview folder within mysite...is it? / does preview have a ____init____.py ?
Jack