ImportError exception exception value: no module with the form name

I have covered most of these issues here, and have not yet found one to help me narrow this down.

I ran into this error and still could not solve it. I initially had to battle multiple files to mix tabs and spaces. Now that I got rid of this error, now I get this error if someone can point me in the right direction, which would be great.

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 file

 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}) 
+4
source share
1 answer

Check the value and location of the exception:

 Exception Type: ImportError Exception Value: No module named forms Exception Location: /home/chad/newssite/links/views.py in <module>, line 3 

Line 3 of your view.py is trying to import from forms.py, which should be in the same directory as your view.py. Make sure your forms.py file is in the same directory or it imports where it really lives.

+5
source

Source: https://habr.com/ru/post/1498879/


All Articles