Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有Chair一个CharField名为wood_type.
Chair
CharField
wood_type
我想用wood_typewhich is not过滤所有椅子''。
''
使用 Django 的优雅方式是什么?
我能想到这个:
Chair.objects.filter(~django.db.models.Q(wood_type=''))
或这个:
Chair.objects.filter(wood_type__regex='(.|\n)+')
但他们丑得要死。有没有更优雅的方式?
Chair.objects.exclude(wood_type='')应该做的伎俩。
Chair.objects.exclude(wood_type='')
exclude the empty string