2013-08-26 4 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

확인 예외 값과 위치 : 당신의 views.py의 3에 있어야 forms.py에서 가져올 시도

Exception Type:  ImportError 
Exception Value:  

No module named forms 

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

라인 귀하의 views.py와 동일한 디렉토리. forms.py 파일이 같은 디렉토리에 있는지 확인하십시오. 그렇지 않으면 실제로 존재하는 곳에서 가져와야합니다.

+1

내 오 마이, 나 바보 야. 실제로 form.py는 디렉토리에있었습니다. S. 마이너스 – DynaMc

관련 문제