Django

Code

Ticket #2936: add_hash_to_model.diff

File add_hash_to_model.diff, 0.5 kB (added by favo@exoweb.net, 2 years ago)

add hash to django.db.model.base

  • django/db/models/base.py

    old new  
    8888    def __ne__(self, other): 
    8989        return not self.__eq__(other) 
    9090 
     91    def __hash__(self): 
     92        return hash(str(self._get_pk_val())) 
     93 
    9194    def __init__(self, *args, **kwargs): 
    9295        dispatcher.send(signal=signals.pre_init, sender=self.__class__, args=args, kwargs=kwargs) 
    9396        for f in self._meta.fields: