I\'ve got a model eg. Car with a foreign key eg. Owner, which may or may not be blank. The Car has a creation_date.
I would like to order these cars by date, but if
This is possible by falling back to SQL:
Car.objects.filter(...).extra(select={'odate': ''' if(owner_id, (select date_of_birth from owner_table where id=owner_id), creation_date ) '''}).order_by('odate')
if function is MySQL-specific. In case of SQLite or Postgres you should use case statement.
if
case