AttributeError on /notify/ 'user' object has no attribute 'get'


Ahmed Yasin

When I create the user object, in views.py. It shows me and the error AttributeError at /notify/ , 'User' object has no attribute 'get', how can I fix it.

from django.contrib.auth.models import User

class NotifyView(TemplateView):
    template_name ='notify/home.html'

    def get(self,request,*args, **kwargs):
        print('oye',request.user)
        user = User.objects.get(username=request.user)
        user.notifications.mark_all_as_read(user) 
        return user

If more info is needed than tell me in a comment thread, I'll update my question with that info. Thanks!

Us_haf

Change the function name to something like "get_user" or "get_object".

Related


AttributeError on /notify/ 'user' object has no attribute 'get'

Ahmed Yasin When I create the user object, in views.py. It shows me and the error AttributeError at /notify/ , 'User' object has no attribute 'get', how can I fix it. from django.contrib.auth.models import User class NotifyView(TemplateView): template_nam

AttributeError on /notify/ 'user' object has no attribute 'get'

Ahmed Yasin When I create the user object, in views.py. It shows me and the error AttributeError at /notify/ , 'User' object has no attribute 'get', how can I fix it. from django.contrib.auth.models import User class NotifyView(TemplateView): template_nam

AttributeError: object of type 'user' has no attribute 'name'

Freddie Martinez Garcia I am new to graphene and I have this: from django.contrib.auth.models import User class UserType(DjangoObjectType): class Meta: model = User Basically, using Django's User class gives me this error because before using the

AttributeError: 'user' object has no attribute 'is_admin'

strontium I customized the user model by extending AbstractBaseUser which accepts only as email id. Here is the model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField('email address', unique=True) first_name = models.CharField

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: type object 'user' has no attribute 'query'

Mark Herbert I have a large database, populated with sqlalchemy (original database - not flask-SQLAlachemy). I'm trying to add flask-security to a website, I realize it relies on flask-SQLAlachemy (not the original), but flask-SQLAlchemy can work with me (just

AttributeError: object of type 'user' has no attribute 'name'

Freddie Martinez Garcia I am new to graphene and I have this: from django.contrib.auth.models import User class UserType(DjangoObjectType): class Meta: model = User Basically, using Django's User class gives me this error because before using the

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'user' object has no attribute 'is_admin'

strontium I customized the user model by extending AbstractBaseUser which accepts only as email id. Here is the model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField('email address', unique=True) first_name = models.CharField

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

FastAPI AttributeError: 'User' object has no attribute 'password'

Du Jie I have a FastAPI project where I use Async SQLAlchemy orm and postgresql as database. Basically it's a simple CRUD based job board, I have successfully created CRUD operations and they work as I expect. The problem I stumbled upon is user authentication

AttributeError: object of type 'user' has no attribute 'name'

Freddie Martinez Garcia I am new to graphene and I have this: from django.contrib.auth.models import User class UserType(DjangoObjectType): class Meta: model = User Basically, using Django's User class gives me this error because before using the

AttributeError: 'user' object has no attribute 'is_admin'

strontium I customized the user model by extending AbstractBaseUser which accepts only as email id. Here is the model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField('email address', unique=True) first_name = models.CharField

AttributeError: 'user' object has no attribute 'is_admin'

strontium I customized the user model by extending AbstractBaseUser which accepts only as email id. Here is the model: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField('email address', unique=True) first_name = models.CharField

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'WSGIRequest' object has no attribute 'user'

Zhiyuan Leng I am running Django code and I am getting this error AttributeError: 'WSGIRequest' object has no attribute 'user' My Django version is 1.8.2 and this is my middleware class setting.py MIDDLEWARE_CLASSES = ( 'khxia.middlewares.PeeweeConnectionMid

AttributeError: 'list' object has no attribute 'get'?

rts this is the script def validate_record_schema(record): device = record.get('Payload', {}) manual_added= device.get('ManualAdded', None) location = device.get('Location', None) if isinstance(manual_added, dict) and isinstance

AttributeError: 'str' object has no attribute 'get'

Wilken When the error occurs, I'm not quite sure how to fix it, there is a nested dictionary where the last item doesn't contain the required get and gives the error, but not sure how to fix it. call very basic code for keys in interfaces: counters = i

Credstash: 'module' object has no attribute 'get': AttributeError

Onka I'm trying to use credstash to access credentials stored in KMS, however, even before accessing them, the python 2.7 lambda runtime on aws gives me an error: 'module' object has no attribute 'get': AttributeError Traceback (most recent call last): File

AttributeError | model object has no attribute 'get'

Chidananda Nayak this is my model class Leave_Management(models.Model): employee = models.ForeignKey('employeeModel', on_delete=models.CASCADE) name = models.CharField(max_length=50) reason = models.TextField(max_length=200) date_to = models.Da

AttributeError: 'InstrumentedList' object has no attribute 'get'

Joanna The minutes_id is not being passed correctly when rendering the html template. Throws error: "AttributeError: 'InstrumentedList' object has no attribute 'get'". I am not sure how to fix this problem. This is the line of code that blows my mind.minutes =

AttributeError: 'QTextBrowser' object has no attribute 'get'

best rookie I'm trying to put functionality into my UI where lineEditI can type and send buttons and then I can forward the text to textBrowsersomething to display, but I'm getting an error. AttributeError: 'QTextBrowser' object has no attribute 'get' from PyQ