Hi,
I have a very strange error which pops up when inserting the crispy tag. Can anybody help?
Django Version: 1.6.6
Python Version: 3.3.2
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'frontpage',
'reg',
'login',
'reports',
'crispy_forms')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Template error:
In template /home/dashcreator/dashboard/login/templates/login.html, error at line 19
No module named 'views'
9 :
10 :
11 : {% block login %}
12 : <br>
13 : <br>
14 : <br>
15 : <br>
16 : <br>
17 : <div class="container">
18 : <div class="row">
19 : {% crispy form form.helper %}
20 : {{ form }}
21 : </div>
22 : </div>
23 :
24 : <br>
25 : <br>
26 : <br>
27 : <br>
28 : <br>
29 :
Traceback:
File "/usr/local/lib/python3.3/dist-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/dashcreator/dashboard/login/views.py" in loginrequest
37. return render_to_response('login.html',context, context_instance = RequestContext(request))
File "/usr/local/lib/python3.3/dist-packages/django/shortcuts/__init__.py" in render_to_response
29. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/local/lib/python3.3/dist-packages/django/template/loader.py" in render_to_string
169. return t.render(context_instance)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in render
140. return self._render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python3.3/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/loader_tags.py" in render
123. return compiled_parent._render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in _render
134. return self.nodelist.render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python3.3/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/loader_tags.py" in render
62. result = block.nodelist.render(context)
File "/usr/local/lib/python3.3/dist-packages/django/template/base.py" in render
840. bit = self.render_node(node, context)
File "/usr/local/lib/python3.3/dist-packages/django/template/debug.py" in render_node
78. return node.render(context)
File "/home/dashcreator/.local/lib/python3.3/site-packages/crispy_forms/templatetags/crispy_forms_tags.py" in render
207. c = self.get_render(context)
File "/home/dashcreator/.local/lib/python3.3/site-packages/crispy_forms/templatetags/crispy_forms_tags.py" in get_render
119. response_dict = self.get_response_dict(helper, context, is_formset)
File "/home/dashcreator/.local/lib/python3.3/site-packages/crispy_forms/templatetags/crispy_forms_tags.py" in get_response_dict
153. attrs = helper.get_attributes(template_pack=self.template_pack)
File "/home/dashcreator/.local/lib/python3.3/site-packages/crispy_forms/helper.py" in get_attributes
358. if self.form_action:
File "/home/dashcreator/.local/lib/python3.3/site-packages/crispy_forms/helper.py" in get_form_action
234. return reverse(self._form_action)
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in reverse
536. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in _reverse_with_prefix
403. self._populate()
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in _populate
290. for name in pattern.reverse_dict:
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in reverse_dict
315. self._populate()
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in _populate
303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in callback
230. self._callback = get_callable(self._callback_str)
File "/usr/local/lib/python3.3/dist-packages/django/utils/functional.py" in wrapper
32. result = func(*args)
File "/usr/local/lib/python3.3/dist-packages/django/core/urlresolvers.py" in get_callable
97. mod = import_module(mod_name)
File "/usr/lib/python3.3/importlib/__init__.py" in import_module
90. return _bootstrap._gcd_import(name[level:], package, level)
Exception Type: ImportError at /login/loginrequest/
Exception Value: No module named 'views'
my views.py
from django.shortcuts import render_to_response, render
from django.http.response import HttpResponse, StreamingHttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.core.context_processors import csrf
from login.forms import LoginForm
from django.template import RequestContext
from django.contrib.auth.models import User
def loginrequest(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/index')
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
username = form.cleaned_data['username']
password = form.cleaned_data['password']
reg = authenticate(username=username, password=password)
if reg is not None:
login(request, reg)
return HttpResponseRedirect('/index')
else:
context = {'form':form}
return render_to_response('login.html',context, context_instance = RequestContext(request))
else:
context = {'form':form}
#messages.error(request, "Please correct the errors below and resubmit.")
return render_to_response('login.html',context, context_instance = RequestContext(request))
else:
form = LoginForm()
context = {'form':form}
return render_to_response('login.html',context, context_instance = RequestContext(request))
my forms.py
class LoginForm(forms.Form):
username = forms.CharField(
label = "username",
max_length = 80,
required = True,
)
password = forms.CharField(
label = "password",
max_length = 80,
required = True,
widget = forms.PasswordInput(render_value = False)
)
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_id = 'id-LoginForm'
self.helper.form_class = 'blueForms'
self.helper.form_method = 'POST'
#self.helper.form_action = '/auth/'
self.helper.add_input(Submit('submit', 'Submit'))