python - Django-models. Complex request to database -


I need to make special requests for the database through the DNS.

For example:

  class model (models.model): name = models.CharField () date = models.DateTimeField () other = models.TextField ()  

I will ask for the row, whose name is containe word 'Hello' (This first letter is the unknown word unknown), it should be on the date dyspasan between the example 2005.08. 09 and 2005.08.11 ?

Example

Try the following:

  start_date = datetime. Date (2005, 8, 9) end_date = datetime.date (2005, 8, 11) Model.objects.filter (name__icontains = "Hello"). Filters (date_range (start_date, end_date))  

You can pile up as many filters as you want and this is a single SQL query (or whatever database system you use)


Comments