当我尝试在Timepiece中创建一个新项目时,项目会添加到我的模型中,因为我可以在后端看到,但视图给了我一个TemplateSyntaxError。
它声明:
Caught ImproperlyConfigured while rendering: settings.AJAX_LOOKUP_CHANNELS not configured correctly for 'user'
django docs告诉我,我的settings.py中缺少一个设置。但我不知道哪个。
如果非常明显,请原谅。
我的追溯:
环境:
Request Method: GET
Request URL: http://localhost:8000/timepiece/project/13/
Django Version: 1.3.1
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.markup',
'django.contrib.flatpages',
'pagination',
'ajax_select',
'timepiece',
'debug_toolbar',
'django_extensions']
Installed Middleware:
('django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Template error:
In template /Users/Bair1/virtualenvs/erp/erp/apps/timepiece/templates/timepiece/project/view.html, error at line 41
Caught ImproperlyConfigured while rendering: settings.AJAX_LOOKUP_CHANNELS not configured correctly for 'user'
31 : <a title='Remove {{ user.get_full_name }}' href='{% url remove_user_from_project project_id=project.id,user_id=user.id %}?next={% url view_project project_id=project.id %}'><img alt='Remove {{ user.get_full_name }}' src='{{ FAMFAMFAM_URL }}/delete.png' /></a>
32 : {% endif %}
33 : </li>
34 : {% endfor %}
35 : {% endifnotequal %}
36 : </ul>
37 : {% if perms.timepiece.add_projectrelationship %}
38 : <form id="add-user" action='{% url add_user_to_project project_id=project.id %}?next={% url view_project project_id=project.id %}' method="post" accept-charset="utf-8">
39 : {% csrf_token %}
40 : <div class="field-wrapper">
41 : {{ add_user_form }}
42 : <input type="submit" name="submit" value="Add" id="submit" />
43 : </div>
44 : </form>
45 : {% endif %}
46 : </div>
47 :
48 : <table class='vertical'>
49 : <tr>
50 : <th>Type:</th>
51 : <td>{{ project.type }}</td>
Traceback:
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/db/transaction.py" in inner
217. res = func(*args, **kwargs)
File "/Users/Bair1/virtualenvs/erp/erp/apps/timepiece/utils.py" in wrapper
63. context_instance=RequestContext(request),
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
188. return t.render(context_instance)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in render
123. return self._render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/loader_tags.py" in render
64. result = block.nodelist.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/defaulttags.py" in render
311. return self.nodelist_true.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/debug.py" in render_node
73. result = node.render(context)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/template/debug.py" in render
92. output = force_unicode(output)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/utils/encoding.py" in force_unicode
71. s = unicode(s)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/forms/forms.py" in __unicode__
95. return self.as_table()
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/forms/forms.py" in as_table
217. errors_on_separate_row = False)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/forms/forms.py" in _html_output
180. 'field': unicode(bf),
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/forms/forms.py" in __unicode__
408. return self.as_widget()
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/django/forms/forms.py" in as_widget
439. return widget.render(name, self.value(), attrs=attrs)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/ajax_select/fields.py" in render
35. lookup = get_lookup(self.channel)
File "/Users/Bair1/virtualenvs/erp/lib/python2.7/site-packages/ajax_select/__init__.py" in get_lookup
115. raise ImproperlyConfigured("settings.AJAX_LOOKUP_CHANNELS not configured correctly for %r" % channel)
Exception Type: TemplateSyntaxError at /timepiece/project/13/
Exception Value: Caught ImproperlyConfigured while rendering: settings.AJAX_LOOKUP_CHANNELS not configured correctly for 'user'
答案 0 :(得分:0)
您似乎正在使用django_ajax_selects
项目,该项目需要在主AJAX_LOOKUP_CHANNEL
中设置settings.py
,以便将模型映射到字段。类似的东西:
AJAX_LOOKUP_CHANNELS = {
'person' : {'model':'example.person', 'search_field':'name'}
}
(来自它的文档)