AG
brand_name = ''
if product.brand:
brand_name = product.brand.name
Size: a a a
AG
brand_name = ''
if product.brand:
brand_name = product.brand.name
OS
OS
>>> Client.objects.annotate(
... discount=Case(
... When(registered_on__lte=a_year_ago, then=Value('10%')),
... When(registered_on__lte=a_month_ago, then=Value('5%')),
... default=Value('0%'),
... output_field=CharField(),
... )
... ).values_list('name', 'discount')
AG
Client.objects.annotate(Или так:
new_name=Case(
When(product__brand__isnull=False, then=F("product__brand__name")),
default=None,
output_field=CharField()
)
).annotate(
brand_name=Coalesce(new_name, Value(""))
)
Client.objects.annotate(** поправил "Coalesce"
brand_name=Coalesce(F("product__brand__name"), Value(""))
)
OS
Client.objects.annotate(Или так:
new_name=Case(
When(product__brand__isnull=False, then=F("product__brand__name")),
default=None,
output_field=CharField()
)
).annotate(
brand_name=Coalesce(new_name, Value(""))
)
Client.objects.annotate(** поправил "Coalesce"
brand_name=Coalesce(F("product__brand__name"), Value(""))
)
AG
A
S
S
A
S
A
НК
A
НК
AG
encoded
- это base64attachments = []
for invoice, encoded in self.get_pdf_invoice():
attachment = Attachment()
attachment.file_content = FileContent(encoded)
attachment.file_type = FileType('application/pdf')
attachment.file_name = FileName(f'{invoice.number}.pdf')
attachment.disposition = Disposition('attachment')
attachments.append(attachment)
return attachments
НК
encoded
- это base64attachments = []
for invoice, encoded in self.get_pdf_invoice():
attachment = Attachment()
attachment.file_content = FileContent(encoded)
attachment.file_type = FileType('application/pdf')
attachment.file_name = FileName(f'{invoice.number}.pdf')
attachment.disposition = Disposition('attachment')
attachments.append(attachment)
return attachments
А
АА