On Tue, May 7, 2019, 12:35 PM Soumen Khatua <[email protected] wrote:
> Hi Folks, > > I didn't understand this code please help me to understand this code. > > class AddressQueryset(models.QuerySet): > def annotate_default(self, user): > # Set default shipping/billing address pk to None > # if default shipping/billing address doesn't exist > default_shipping_address_pk, default_billing_address_pk = None, > None > if user.default_shipping_address: > default_shipping_address_pk = user.default_shipping_address.pk > if user.default_billing_address: > default_billing_address_pk = user.default_billing_address.pk > return user.addresses.annotate( > user_default_shipping_address_pk=Value( > default_shipping_address_pk, models.IntegerField()), > user_default_billing_address_pk=Value( > default_billing_address_pk, models.IntegerField())) > > > default_shipping_address & default_billing_address_pk is available in my > User table it is a foreignkey of Address table and addresses is also > avialable in my User table as ManytoManytoField refering to same Address > Table and the last i'm using this inside Address table just like this : > objects = AddressQueryset.as_manager() > > > > 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 [email protected]. > To post to this group, send email to [email protected]. > 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/CAPUw6Wbb9Emmq0aODhK9GmT9Z8X0TMQtSOsPJ-SA-99mpdT6sg%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAPUw6Wbb9Emmq0aODhK9GmT9Z8X0TMQtSOsPJ-SA-99mpdT6sg%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 [email protected]. To post to this group, send email to [email protected]. 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/CAOs61rwsOdXyWTi%2BxhWO%3DybO2sLF77dmris_Au0Q1gsrUMhuCQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

