Yes,You are right as_data is custom made function inside the same class,here is the code:
def as_data(self): """Return the address as a dict suitable for passing as kwargs.Result does not contain the primary key or an associated user.""" data = model_to_dict(self,exclude=['id','user']) if isinstance(data['country'], Country): data['country'] = data['country'].code if isinstance(data['phone'], PhoneNumber): #as_e164 is a phonenumber format information data['phone'] = data['phone'].as_e164 return data But here other is an argument so we need to pass it then without passing how we can compare with self.as_data varibale? Thank you for your response. On Tue, May 7, 2019 at 2:19 AM Skyisblue <jreitma...@gmail.com> wrote: > Soumen, > > The function looks to compare two Address objects. The as_data() call is > custom made. I saw it documented in your other post. It removes the Primary > Key and User from the Address object. I presume this is so they can compare > the hash of one address to the hash of another. > > Regards, > Joe > > On Mon, May 6, 2019 at 6:03 AM Soumen Khatua <soumenkhatua...@gmail.com> > wrote: > >> Hi Folks, >> >> How this underline code works? >> >> >> models.py >> >> class Address(models.Model): >> first_name = models.CharField(max_length=256, blank=True) >> last_name = models.CharField(max_length=256, blank=True) >> company_name = models.CharField(max_length=256, blank=True) >> street_address_1 = models.CharField(max_length=256, blank=True) >> street_address_2 = models.CharField(max_length=256, blank=True) >> city = models.CharField(max_length=256, blank=True) >> city_area = models.CharField(max_length=128, blank=True) >> postal_code = models.CharField(max_length=20, blank=True) >> country = CountryField() >> country_area = models.CharField(max_length=128, blank=True) >> phone = PossiblePhoneNumberField(blank=True, default='') >> >> >> *def __eq__(self, other):* >> * return self.as_data() == other.as_data()* >> * __hash__ = models.Model.__hash__* >> >> >> Thank you. >> >> >> >> >> >> >> >> >> >> >> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-users+unsubscr...@googlegroups.com. >> To post to this group, send email to django-users@googlegroups.com. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAPUw6WY-pNGnPBHzDA%3DiRZUHY7NrmK30_dMbKiQpe%2B1n%2ByW%2BQQ%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAPUw6WY-pNGnPBHzDA%3DiRZUHY7NrmK30_dMbKiQpe%2B1n%2ByW%2BQQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAGgUuiuun1NebT1V5r2v3GGjSCJ4RybUw9Fsn1g4M6x1ei2VQw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGgUuiuun1NebT1V5r2v3GGjSCJ4RybUw9Fsn1g4M6x1ei2VQw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6Wbdko08d210HbV5uv8EBeWiC6Q%3D8LKdfyyYKHN--7__pA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.