Django comparing model instances for equality

后端 未结 8 1793
夕颜
夕颜 2020-12-01 11:53

I understand that, with a singleton situation, you can perform such an operation as:

spam == eggs

and if spam and eggs

8条回答
  •  日久生厌
    2020-12-01 12:28

    You can define the Class' __eq__ method to chage that behaviour:

    http://docs.python.org/reference/datamodel.html

提交回复
热议问题