for u in Users.objects.all():
for g in u.group.all():
if g not in Groups.objects.filter(domain__user=u.id):
u.group.filter(id=g.id).delete()
어떻게 관계 테이블의 항목을 삭제합니까? 이 경우 그룹과
을 감안할 때 : from django.db import models
class Food(models.Model):
"""Food, by name."""
name = models.CharField(max_length=25)
class Cat(models.Model):
"""A cat eats one type of food"
Projectfundingdetail에 외래 키가 있습니다. 다음 쿼리는 인 프로젝트의 목록을 제공합니다.이 프로젝트의 세부 프로젝트 내용은입니다. 어떻게 프로젝트를 최신 프로젝트 세부 사항으로 제한합니까? projects_list.filter(projectfundingdetail__budget__lte=1000).distinct()
나는 다음과 같은
를 사용하여 최대 값을 기준으로 하나의 자식 행을 가져 오는 계약과 함께 시장 객체를 최대 가격으로 가져 오는 것을 좋아합니다. 이것은 원시 SQL을 통해 수행하는 방법입니다. SELECT M.id as market_id, M.name as market_name, C.name as contract_name, C.price
as price from pm_c