B station Django project fresh learning every day | using the 'get_default_address' function can not get the default address

Environment: win10, Python3.7, Django2.2.15
insert image description here
Checked it out, some big guys said that they can write their own method, I am lazy,
insert image description here
I directly use the ordinary query method

address = Address.objects.get(user=user,is_default=True)

Finish!
Experience: I was too lazy to write code, so I took the code from the boss and used it, but I had to write the model manager class myself. It's better to use the teacher's from the beginning.

Guess you like

Origin blog.csdn.net/xiaoluobotm/article/details/123906286