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 2,224 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
241 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
562 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
271 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,740 points
457 views
0 votes
1 answer

Please name some online websites to compile and run PL/SQL?

For executing Oracle SQL queries and PL/SQL ...READ MORE

answered Feb 11 in Database by Neha
• 8,560 points
105 views
0 votes
1 answer
0 votes
0 answers

SQL: Display Full Name + Filter By Subject

Feb 22 in Database by Neha
• 8,560 points
23 views
0 votes
0 answers

How to get address, Column Name and Row Name of all marked rows in Excel table as rows in new worksheet

 need the row/column combinations marked with an ...READ MORE

Feb 24 in Database by Edureka
• 13,640 points
236 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP