How to send user's full name and email to database with django

Question:

When I try to send the full name and email, it returns a value like this

<bound method AbstractUser.get_full_name of <User: keremedeler>>

To send the e-mail, I added a function like this to the models.py file of the user class, and it sent a response like this:

<bound method AbstractUser.get_email of <User: keremedeler>>

def get_email(self):
        email = self.email
Asked By: Ahmet

||

Answers:

It looks like you are trying to access the email and get_full_name attributes of a Django User object, but you are using the incorrect syntax to do so. In Django, when you have an instance of a model class, you can access its attributes using the dot (.) notation. So, to access the email attribute of the User object, you would use the following syntax:

user = User.objects.get(pk=1)
email = user.email

Similarly, to access the get_full_name method of the User object, you would use the following syntax:

user = User.objects.get(pk=1)
full_name = user.get_full_name()

Note that the get_full_name method is a method, so it needs to be called with the parentheses (()) at the end.

Answered By: Haris
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.