Quantcast
Viewing latest article 9
Browse Latest Browse All 20

Dynamic Django queries (or why kwargs is your friend)

A very easy way to dynamically build queries in Django is to use Python kwargs (keyword arguments). Let’s say we have a model that looks something like this: class Entry( models.Model ): user = models.ForeignKey( User, related_name = 'entries' ) category = models.ForeignKey( Category, related_name = 'entries' ) title = models.CharField( max_length = 64 ) [...]

Viewing latest article 9
Browse Latest Browse All 20

Trending Articles