NoneType object has no attribute name

0 votes

in the models.py:

name = models.CharField(max_length=50, db_index=True)
gender = models.CharField(max_length=2, null=False, choices=GENDER_TYPE, blank=True)


in  the context_helper.py:
def get_emp_info(employee):
    
    blood_groups = blood_group_helper()
    genders = gender_helper()
    info = {
        'ename': employee.name,
        'dob': employee.dob,
        'gender': [i for i in genders if employee.gender in i],
        'phone': employee.phone,
        'address': employee.curr_address,
        'emp_id': employee.e_id,
        'bgroup': [i for i in blood_groups if employee.blood_group in i],
        'photo': os.path.join(settings.MEDIA_URL, employee.photo.name) if employee.photo else None,
    }
    return info


and the error says:

  File "C:\Users\Administrator\placement\placement\helpers\context_helper.py", line 109, in get_emp_info
    'ename': employee.name,
AttributeError: 'NoneType' object has no attribute 'name'

What is the problem and how to resolve in it?

Jun 18, 2020 in Database by prince
• 120 points

edited Jun 18, 2020 by Gitika 1,803 views

Hi, @Prince,

It means the Employee has None.

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
1 answer

Can different databases use different name quotes?

This use of quotes is called delimited ...READ MORE

answered Sep 11, 2018 in Database by CodingByHeart77
• 3,720 points
185 views
0 votes
1 answer

How will I get all the rows from my table where name starts with 's' and ending with 'I'?

Hi Santanu, I understand your problem, You can try ...READ MORE

answered May 28, 2019 in Database by sampriti
• 1,120 points
318 views
0 votes
1 answer

How can I change my existing database name?

Hey Partha, I understand your problem, I think this ...READ MORE

answered Jul 5, 2019 in Database by sampriti
• 1,120 points
198 views
0 votes
1 answer
0 votes
1 answer

How to set SSL to Domain name for MYSQL database

Hello @ Lakshminarayanan, Yes, It is possible to setup ...READ MORE

answered Jul 9, 2020 in Database by Niroj
• 82,880 points
312 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

AttributeError: 'NoneType' object has no attribute 'find'

Hi@akhtar, It seems Sklearn is not installed properly ...READ MORE

answered Jun 23, 2020 in Python by MD
• 95,320 points
4,362 views
0 votes
1 answer

Error:AttributeError: 'NoneType' object has no attribute 'extend'

Hello @kartik, You can use itertools.chain(): import itertools list2d = [[1,2,3], ...READ MORE

answered Nov 18, 2020 in Python by Niroj
• 82,880 points
1,202 views
0 votes
1 answer

'NoneType' object has no attribute 'text

Hello @Muhammad Umer, As per the Beautiful Soup Documentation: AttributeError: ...READ MORE

answered Dec 7, 2020 in Python by Niroj
• 82,880 points
12,132 views