2013-08-26 19 views
4

我已經通過了大部分類似的問題在這裏,所以迄今還沒有找到一個幫助我縮小範圍。ImportError異常值:沒有模塊命名形式

我遇到了這個錯誤,還沒有能夠解決它。我原本不得不與幾個文件混合製表符和空格。現在我已經擺脫了那個錯誤,現在我得到了這個錯誤,如果任何人都能指出我會朝着正確的方向發展的話。

ImportError at/

No module named forms 

Request Method:  GET 
Request URL: http://127.0.0.1:8000/ 
Django Version:  1.5.2 
Exception Type:  ImportError 
Exception Value:  

No module named forms 

Exception Location:  /home/newssite/links/views.py in <module>, line 3 
Python Executable: /usr/bin/python 
Python Version:  2.7.3 
Python Path:  

['/home/chad/newssite', 
'/usr/local/lib/python2.7/dist-packages/django_registration-1.0-py2.7.egg', 
'/usr/lib/python2.7', 
'/usr/lib/python2.7/plat-linux2', 
'/usr/lib/python2.7/lib-tk', 
'/usr/lib/python2.7/lib-old', 
'/usr/lib/python2.7/lib-dynload', 
'/usr/local/lib/python2.7/dist-packages', 
'/usr/lib/python2.7/dist-packages',  '/usr/lib/python2.7/dist-packages/PIL', 
'/usr/lib/python2.7/dist-packages/gst-0.10', 
'/usr/lib/python2.7/dist-packages/gtk-2.0', 
'/usr/lib/pymodules/python2.7', 
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client', 
'/usr/lib/python2.7/dist-packages/ubuntuone-client', 
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', 
'/usr/lib/python2.7/dist-packages/ubuntuone-couch', 
'/usr/lib/python2.7/dist-packages/ubuntuone-installer', 
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol'] 

Server time: Sun, 25 Aug 2013 20:29:20 -0500 

views.py文件

from django.views.generic import ListView, DetailView 
from .models import Link, UserProfile 
from .forms import UserProfileForm 
from django.contrib.auth import get_user_model 
from django.views.generic.edit import UpdateView 
from django.core.urlresolvers import reverse 

class LinkListView(ListView): 
model = Link 
queryset = Link.with_votes.all() 
paginate_by = 5 

class UserProfileDetailView(DetailView): 
model = get_user_model() 
slug_field = "username" 
template_name = "user_detail.html" 

def get_object(self, queryset=None): 
    user = super(UserProfileDetailView, self).get_object(queryset) 
    UserProfile.objects.get_or_create(user=user) 
    return user 
class UserProfileEditView(UpdateView): 
model = UserProfile 
form_class = UserProfileForm 
template_name = "edit_profile.html" 

def get_object(self, queryset=None): 
    return UserProfile.objects.get_or_create(user=self.request.user)[0] 

def get_success_url(self): 
    return reverse("profile", kwargs={"slug": self.request.user}) 
+5

帶'views.py'的目錄還有什麼?有沒有'forms.py'? – user2357112

回答

5

檢查異常值和位置:

Exception Type:  ImportError 
Exception Value:  

No module named forms 

Exception Location:  /home/chad/newssite/links/views.py in <module>, line 3 

線的views.py的3試圖從forms.py這應該是在進口與您的views.py相同的目錄。確保你的forms.py文件在同一個目錄下,或者從它實際存在的地方導入它。

+1

我的噢,我很傻。 form.py實際上是在目錄中。減去S. – DynaMc

相關問題