我已经在这里解决了关于 SO 的大多数类似问题,但到目前为止还没有找到一个可以帮助我缩小范围的问题。
我遇到了这个错误,还没有解决它。我最初不得不使用一些文件来混合制表符和空格。现在我已经摆脱了那个错误,我现在得到了这个错误,如果有人能指出我正确的方向,那就太好了。
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
视图.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})