views:

27

answers:

1

Hi I'm siting with my custom storage system 1 day. And now when I'm trying import it it gives me this Error. I put in file models.py

from FTPStorage import FTPStorage
import datetime
from django.db import models

fs=FTPStorage()

class Upload(models.Model):
    """Uploaded files."""
    file = models.FileField(upload_to='uploads', store=fs)
    timestamp = models.DateTimeField(default=datetime.datetime.now)
    notes = models.CharField(max_length=255, blank=True)

    class Meta:
        ordering = ['-timestamp',]

    def __unicode__(self):
        return u"%s" % (self.file)

    @property
    def size(self):
        return filesizeformat(self.file.size)

here is my views.py:

from forms import UploadForm
from models import Upload
import ftplib
import os
import datetime
from django.forms import save_instance
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from django.http import HttpResponse
from FTPStorage import FTPStorage
from django.core.files.storage import Storage

def initial(request):
    data = {

        'form': UploadForm(),
    }
    return render_to_response('upload.html', data, RequestContext(request))


def upload(request):
    if request.method == 'POST':
        form = UploadForm(request.POST, request.FILES)
        if form.is_valid():
            upload = Upload()
            upload.timestamp = datetime.datetime.now()
            save_instance(form, upload)
            return HttpResponseRedirect(reverse('initial'))

and file custom storage system FTPStorage.py is in direectory app

I have this problem:

Request Method:     GET
Request URL:    http://localhost:2121/
Exception Type:     ViewDoesNotExist
Exception Value:    

Could not import app.views. Error was: cannot import name FTPStorage

Exception Location:     C:\BitNami DjangoStack\apps\django\django\core\urlresolvers.py in _get_callback, line 134

Please help me. I confuse.

+2  A: 

It seems to me that you need to update the PYTHONPATH for your runtime. Based on your error page I think you're using mod_python so try this setting in apache:

PythonPath "sys.path+['/mydir']"  

Where /mydir is the full path to wherever the FTPStorage module resides.

andyortlieb