Quantcast
Channel: Nomad Journey
Viewing all articles
Browse latest Browse all 20

Dynamic Django queries (or why kwargs is your friend)

$
0
0
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 all articles
Browse latest Browse all 20

Trending Articles