- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试构建一个 e_commerc django 应用程序,但我遇到了一个错误,而且有点令人困惑。我的错误是:
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'profiles')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Template error:
In template /home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html, error at line 15
cannot import name contactForm
5 : <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
6 : <span class="sr-only">Toggle navigation</span>
7 : <span class="icon-bar"></span>
8 : <span class="icon-bar"></span>
9 : <span class="icon-bar"></span>
10 : </button>
11 : <a class="navbar-brand" href="#">Bootstrap theme</a>
12 : </div>
13 : <div id="navbar" class="navbar-collapse collapse">
14 : <ul class="nav navbar-nav">
15 : {% url 'home' as home %}
16 : {% url 'about' as about %}
17 : {% url 'contact' as contact %}
18 : <li {% if request.path == home %} class="active" {%endif%}><a href="{% url 'home' %}">Home</a></li>
19 : <li {% if request.path == about %} class="active" {%endif%}><a href="{% url 'about' %}">About</a></li>
20 : <li {% if request.path == contact %} class="active" {%endif%}><a href="{% url 'contact' %}">Contact</a></li>
21 : <li class="dropdown">
22 : <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
23 : <ul class="dropdown-menu" role="menu">
24 : <li><a href="#">Action</a></li>
25 : <li><a href="#">Another action</a></li>
Traceback:
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/petarp/Documents/Udemy/Learn_Django/source/profiles/views.py" in home
7. return render(request, tempalte, context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/shortcuts.py" in render
50. return HttpResponse(loader.render_to_string(*args, **kwargs),
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
178. return t.render(context_instance)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
126. return compiled_parent._render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
150. return template.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
148. return self._render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
142. return self.nodelist.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
844. bit = self.render_node(node, context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
80. return node.render(context)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render
444. url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse
551. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
415. self._populate()
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate
303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback
231. self._callback = get_callable(self._callback_str)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/utils/lru_cache.py" in wrapper
101. result = user_function(*args, **kwds)
File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable
97. mod = import_module(mod_name)
File "/usr/lib/python2.7/importlib/__init__.py" in import_module
37. __import__(name)
File "/home/petarp/Documents/Udemy/Learn_Django/source/contact/views.py" in <module>
3. from .forms import contactForm
Exception Type: ImportError at /
Exception Value: cannot import name contactForm
我不明白这个错误,或者更好地说我看不到这个错误。这是我的views.py和 forms.py 。为什么他不能导入contactForm?有人可以解释一下我该如何克服这个问题。保护你。
最佳答案
我认为你在 forms.py 中犯了一个错误。
请确保您正确拼写了 contactForm
函数。在 contactForm
中,F
必须大写。
class contactForm(forms.Form):
关于python - 导入错误(无法导入姓名 contactForm ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28555202/
我有一个在 bootstrap 中制作的联系表。当我检查元素时,我发现它从 .well 类中获取 CSS 属性 在这个类中,背景颜色设置为: background-color: #f5f5f5; 我修
我正在尝试构建一个 e_commerc django 应用程序,但我遇到了一个错误,而且有点令人困惑。我的错误是: Environment: Request Method: GET Request U
无论我以何种方式实现我的表单,我都会收到以下错误。当我转到表单的 URL 时会发生这种情况。 表单.py class ContactForm(forms.ModelForm): class M
我正在尝试使用 flask 创建联系表单,但在呈现页面时不断出现此错误。 'forms.ContactForm object' has no attribute 'hidden_tag' 这是我的文件
任何人都可以分享一些指南、技巧或链接,这些指南、提示或链接是什么构成创建模型的最佳实践的最佳实践,该模型表示没有由数据库中的表备份但仍然可以验证输入的数据的联系表单? 谢谢。 编辑:我忘了提到,如果它
我想使用 JQuery 向 Spring Controller 发送 POST 请求,但我不断从 jquery 收到此错误 Could not read document: Unrecognized
我是一名优秀的程序员,十分优秀!