'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 in Database by prince
• 120 points

edited Jun 18 by Gitika 275 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,710 points
67 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,100 points
117 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 4, 2019 in Database by sampriti
• 1,100 points
71 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 in Database by Niroj
• 44,800 points
56 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 22 in Python by MD
• 42,420 points
365 views
0 votes
2 answers
0 votes
2 answers

AttributeError: 'module' object has no attribute 'Serial'

I see where the problem is. I ...READ MORE

answered Aug 14, 2018 in IoT (Internet of Things) by DataKing99
• 8,150 points
4,360 views