- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我添加一个表单来添加电话号码时,一切正常。
但是,当我为 full_name 添加字段时,出现此错误:
ViewDoesNotExist at /phone/ Could not import accounts.views.add_phone. View does not exist in module accounts.views..
class PhoneForm(forms.Form):
phone = forms.IntegerField()
full_name = forms.Charfield()
def add_phone(request):
if request.method == 'POST':
form = phone_name_form(request.POST)
if form.is_valid():
phone = form.cleaned_data['phone']
#fullname = form.cleaned_data['fullname']
user = request.user
#store phone number to user profile
user.get_profile().phone = phone
user.get_profile().save()
#store fullname in the "firstname" field for User
# print "fullname"
#print fullname
return HttpResponseRedirect("/menu/")
else:
form = phone_name_form() #an unbound form
return render_to_response("phone_form.html", {'form' : form}, context_instance=RequestContext(request))
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^signup/$', 'accounts.views.signup'),
url(r'^accounts/', include('registration.backends.simple.urls')),
url(r'^phone/$', 'accounts.views.add_phone'),
url(r'^users/', 'accounts.views.register_complete'),
url(r'^$', 'food.views.menu'),
url(r'^menu/$', 'food.views.menu'),
url(r'^menu/(?P<hour>\d+)/$', 'food.views.menu_hour'),
url(r'^menu/(?P<hour>\d+)/(?P<food>\w+)/$', 'cart.views.add_to_cart_view'),
url(r'^images/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
url(r'^cart/', include('cart.urls')),
url(r'^checkout/', 'cart.views.checkout'),
#url(r'^menu/12/$', 'food.views.menu_hour'),
# Examples:
# url(r'^$', 'foodchute.views.home', name='home'),
# url(r'^foodchute/', include('foodchute.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
最佳答案
您肯定拼错了表单字段类型。最常见的是大写错误。
不过,Django 应该更准确地报告这一点。
关于django - Django 表单的 ViewDoesNotExist/导入错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12087583/
我有以下代码,如您所见, View 中有一个C_account()函数,但是我仍然在 **Exception Type: ViewDoesNotExist at /create_account/ Ex
我遇到了一个错误: Caught ViewDoesNotExist while rendering: Tried my_view_two in module yourmodule.views. Err
我正在尝试解决一个问题:Django 告诉我我的 View 不存在,但我创建了一个应该以相同名称加载的 View 。我有以下错误: ViewDoesNotExist at / Could not im
当我添加一个表单来添加电话号码时,一切正常。 但是,当我为 full_name 添加字段时,出现此错误: ViewDoesNotExist at /phone/ Could not import ac
我正在研究 Practical Django Proects,但遇到了困难。我收到错误: Caught ViewDoesNotExist while rendering: Tried tagged_o
我在处理具有 FormView 的 View 时遇到问题。我正在尝试使用 s3direct插件。 该错误指定 '' is not a callable or a dot-notation path .
我是一名优秀的程序员,十分优秀!