当我试图在我的request.user文件中使用它时,AttributeError: 'WSGIRequest' object has no attribute 'user'会生成一个AttributeError: 'WSGIRequest' object has no attribute 'user'错误。我做错了什么吗?
Settings.py:
def show_toolbar(request):
if DEBUG:
return True
#if not request.is_ajax()
我正在努力让我的俱乐部网站恢复和运行后,我们以前的程序员离开。他没有留下任何东西,所以现在当我运行它时,Django会给我错误:
File "/home/serverad/django14_project/my_django15_project/tsa/events/views.py", line 112, in custom500 return render_template('errors/500.mako', request, parent='../base.mako' if request.user.is_authenticate
我正在制作一个钱包应用程序,所以如果有人去添加钱,然后按下submit,就必须将钱添加到他们的钱包中,但是在提交之后有一个错误:
AttributeError at /add_money/ 'unicode' object has no attribute 'user'
为了更好地了解行动流程,我设置了一些检查站:
Request <WSGIRequest: GET '/add_money/'>
Request j <WSGIRequest: GET '/add_money/'>
[15/Dec/2016
当使用类继承时,Python3在super() argument 1 must be type, not WSGIRequest中失败了。
我在Django 2.1.4和Python3.7.0上。我试图看看用户是否已经提交了要分析的文件,如果没有,他将被定向到提交页面。我尝试不使用静态方法,检查它是否真的是Python3(因为这个问题在Python2上很常见),在我试图从"object“继承的超类上,同时也从Django提供的"View”继承(因为这在Python2中解决了)。
这是一个超类,它继承了Django "View“提供的类。
class DatasetReq
在我的站点的仪表板上呈现表单上的信息有问题,其中显示用户在注册时输入的信息。
我收到的错误消息是AttributeError at /dashboard/:'WSGIRequest‘对象没有属性'profileuser'
对我做错了什么有什么想法吗?
Models.py:
from django.db import models
from django.contrib.auth.models import User
class ProfileUser(models.Model):
user = models.OneToOneField(User)
b
当我尝试访问localhost:8000/course/u/update-item/:"AttributeError at /update_item/ 'WSGIRequest‘对象没有属性'data'“时,会出现此错误。
注意:当我将request.data更改为request.body时,会收到另一条错误消息,即JSONDecodeError at /course/u/update-item/ Expecting value: line 1 column 1 (char 0)
views.py
def update_item(request):
da
我试图为django应用程序编写一些测试,结果出现了一个错误:
File "/Users/croberts/.virtualenvs/litem/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 101, in login
if SESSION_KEY in request.session:
AttributeError: 'WSGIRequest' object has no attribute 'session'
下面是我试图运行的代码:
class
似乎Python处理AttributeError异常是不标准的。当类定义__getattr__方法时,它会吞并此异常,而不是传播到堆栈顶部。原来的异常丢失了吗?
class A(object):
@property
def test(self):
raise AttributeError('message which should not be lost')
return 'this would never return'
def __getattr__(self, name):
prin