Convert date to datetime in Python

linkaiyi
Follow

Convert date to datetime in Python

from datetime import date
from datetime import datetime

dt = datetime.combine(date.today(), datetime.min.time())

content_type object_id GenericForeignKey

  1. object can be created with content_object=obj
  2. object can not be retrieved backwards by using filter(content_object=obj)
class BarX(Bar):
    name = models.CharField(max_length=10, default='bar x')
    foos = GenericRelation(Foo, related_query_name='bar_x')

class BarY(Bar):
    name = models.CharField(max_length=10, default='bar y')
    foos = GenericRelation(Foo, related_query_name='bar_y')

Foo.objects.filter(bar_x__name='bar x')
Foo.objects.filter(bar_y__name='bar y')
Object has 0 attachments

Was this article helpful?

This article is viewed 16 times!

0 Comments

Leave a Comment

Support