Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django@login\u必需的装饰程序错误_Python_Django - Fatal编程技术网

Python django@login\u必需的装饰程序错误

Python django@login\u必需的装饰程序错误,python,django,Python,Django,我正在运行django 1.1rc。使用django的内置开发服务器,我的所有代码都能正常工作;但是,当我使用Apache的mod_python将其投入生产时,我的所有视图都出现以下错误: Caught an exception while rendering: Reverse for '<django.contrib.auth.decorators._CheckLogin 在呈现时捕获到异常:反向为“在Google上搜索了一下,听起来您可能需要删除服务器上的任何.pyc文件,并让它在

我正在运行django 1.1rc。使用django的内置开发服务器,我的所有代码都能正常工作;但是,当我使用Apache的mod_python将其投入生产时,我的所有视图都出现以下错误:

 Caught an exception while rendering: Reverse for '<django.contrib.auth.decorators._CheckLogin

在呈现时捕获到异常:反向为“在Google上搜索了一下,听起来您可能需要删除服务器上的任何.pyc文件,并让它在第一次访问它们时重新编译它们。

我的apache配置有问题:

我改变了这一点:

SetEnv DJANGO_设置_模块设置

为此:

SetEnv DJANGO_设置_模块增压器。设置


为了解决defualt auth login问题,我添加了设置。login\u URL。

这是Django中非常常见的“幻影错误”。换句话说,您的代码中有一个bug,但调试页面反馈了一个误导性的异常。通常当我看到这个错误时,是因为我在我的一个模板中的url标记中搞错了一些东西——最常见的是一个拼写错误的url或一个我尚未编写的视图的url。很多时候,Django调试页面甚至会突出显示错误来源的url

请发布完整的traceback.slypete-尝试从
{%url…%}
循环中删除所有
{%for patient in patients%}
并查看这是否可以防止异常。如果确实如此,那么您在某个地方发生了无法解决的URL反转。它在任何{%}上都会失败。从简单的打印到url反转。另一件需要考虑的事情是确保产品运行的是Python2.4或更高版本。然而,我只是认为这不是问题所在(并删除了我写的答案)。
Environment:

Request Method: GET
Request URL: http://lghbb/booster/hospitalists/
Django Version: 1.1 rc 1
Python Version: 2.5.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'booster.core',
 'booster.hospitalists']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template c:\booster\templates\hospitalists\my_patients.html, error at line 23
   Caught an exception while rendering: Reverse for '<django.contrib.auth.decorators._CheckLogin object at 0x05016DD0>' with arguments '(7L,)' and keyword arguments '{}' not found.
   13 :                     <th scope="col">Name</th>


   14 :                     <th scope="col">DOB</th>


   15 :                     <th scope="col">IC</th>


   16 :                     <th scope="col">Type</th>


   17 :                     <th scope="col">LOS</th>


   18 :                     <th scope="col">PCP</th>


   19 :                     <th scope="col">Service</th>


   20 :                 </tr>


   21 :             </thead>


   22 :             <tbody>


   23 :              {% for patient in patients %} 


   24 :                 <tr class="{{ patient.gender }} select">


   25 :                         <td>{{ patient.bed }}</td>


   26 :                         <td>{{ patient.mr }}</td>


   27 :                         <td>{{ patient.acct }}</td>


   28 :                         <td><a href="{% url hospitalists.views.patient patient.id %}">{{ patient }}</a></td>


   29 :                         <td>{{ patient.dob }}</td>


   30 :                         <td class="{% if patient.infections.count %}infection{% endif %}">


   31 :                             {% for infection in patient.infections.all %}


   32 :                             {{ infection.short_name }} &nbsp;


   33 :                             {% endfor %}


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\auth\decorators.py" in __call__
  78.             return self.view_func(request, *args, **kwargs)
File "c:/booster\hospitalists\views.py" in index
  50.   return render_to_response('hospitalists/my_patients.html', RequestContext(request, {'patients': patients, 'user' : request.user}))
File "C:\Python25\Lib\site-packages\django\shortcuts\__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "C:\Python25\Lib\site-packages\django\template\loader.py" in render_to_string
  108.     return t.render(context_instance)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in render
  178.         return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "C:\Python25\Lib\site-packages\django\template\debug.py" in render_node
  71.             result = node.render(context)
File "C:\Python25\Lib\site-packages\django\template\loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in render
  178.         return self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "C:\Python25\Lib\site-packages\django\template\debug.py" in render_node
  71.             result = node.render(context)
File "C:\Python25\Lib\site-packages\django\template\loader_tags.py" in render
  24.         result = self.nodelist.render(context)
File "C:\Python25\Lib\site-packages\django\template\__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "C:\Python25\Lib\site-packages\django\template\debug.py" in render_node
  81.             raise wrapped

Exception Type: TemplateSyntaxError at /hospitalists/
Exception Value: Caught an exception while rendering: Reverse for '<django.contrib.auth.decorators._CheckLogin object at 0x05016DD0>' with arguments '(7L,)' and keyword arguments '{}' not found.

Original Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\django\template\debug.py", line 71, in render_node
    result = node.render(context)
  File "C:\Python25\Lib\site-packages\django\template\defaulttags.py", line 155, in render
    nodelist.append(node.render(context))
  File "C:\Python25\Lib\site-packages\django\template\defaulttags.py", line 382, in render
    raise e
NoReverseMatch: Reverse for '<django.contrib.auth.decorators._CheckLogin object at 0x05016DD0>' with arguments '(7L,)' and keyword arguments '{}' not found.