class filter(filters.FilterSet):
filename = django_filters.CharFilter(name='filename', lookup_expr='contains')
state = django_filters.filters.ModelMultipleChoiceFilter(
name='state_id',
to_field_name ='state' ,
queryset=models.IngestionState.objects.all())
http://localhost :8000/ingestion-detail/?filename="{something}"&status=
์์ URL์ ๋น ๊ฒฐ๊ณผ๋ฅผ ์ ๊ณตํฉ๋๋ค.
status = {something}์ผ ๋๋ง ํ์ํ ๊ฒฐ๊ณผ๋ฅผ ์ป๊ณ ์์ต๋๋ค. ์ด๊ฒ์ ModelMultipleChoiceFilter์๋ง ํด๋น๋ฉ๋๋ค.
๊ธ์, ๋น์ ์ด ๋งํ ๊ฒ์ ๋๊ธฐ๊ฐ ์ด๋ ต์ต๋๋ค.
'status' != 'state'
ํ์ง๋ง ์คํ์ธ ๊ฒ ๊ฐ์ต๋๋ค.
from django_filters.constants import STRICTNESS
์๋ ํ๊ณ strict
๋ฉํ ์ต์
์ STRICTNESS.RAISE_VALIDATION_ERROR
. ๊ทธ๊ฒ์ ์ ์ด๋ ๋น์ ์๊ฒ ๋ฌด์ธ๊ฐ๋ฅผ ๋งํด์ผํฉ๋๋ค.
๊ทธ๋ ์ง ์์ผ๋ฉด ๋ด๊ฐ ์ด ๋ฌธ์ ๋ฅผ ๊ณ ๋ คํ๊ธฐ ์ ์ ํจ์ฌ ๋ ๊ตฌ์ฒด์ ์ธ ๊ฒ์ ์๋ํ๊ณ ์๋ณํด์ผ ํฉ๋๋ค. ๋์์ด ํ์ํ ๊ฒฝ์ฐ StackOverflow๊ฐ ๋ ์ ํฉํ ์ ์์ต๋๋ค.
์๋ ํ์ธ์, ์ด ์ํฉ์์ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๊ฐ๋ฅํ ๋ชจ๋ ์ํ๋ฅผ ์ํ ๊ฒฝ์ฐ ๋ด URL์ status=blank๊ฐ ์๋ ๊ฒฝ์ฐ ๋น ๊ฒฐ๊ณผ๋ฅผ ์์ ํ๋ ๋ฐฉ๋ฒ์ ๋ฌด์์ ๋๊น?
from django_filters.constants import STRICTNESS
ImportError: cannot import name 'STRICTNESS'
๋ผ๋ ์ค๋ฅ๊ฐ ํ์๋ฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
from django_filters.constants import STRICTNESS
ImportError: cannot import name 'STRICTNESS'
๋ผ๋ ์ค๋ฅ๊ฐ ํ์๋ฉ๋๋ค.