ranger_delli
ranger_delli

Reputation: 15

__str__ returned non-string (type NoneType)...im receiving this error may be due to a NoneType user model

error in admin panelI'm getting this error, in admin panel other than this the website is working fine.

Here is my forms.pyforms.py

Here is models.pymodels.py

These are in views.pyview1 And this is for new user registrationnew user view

I think the error is happening because the order model is receiving a NoneType customer as a foreign key. But I don't know how to solve this problem. I'm new to django please help me out.

Upvotes: 0

Views: 709

Answers (1)

taha maatof
taha maatof

Reputation: 2165

you can do it like this:

 def __str__(self):
    if self.name:
        return self.name
    else:
        return self.email

you have to return at least something

Upvotes: 2

Related Questions