0
에보기 매개 변수를 만들어이이 장고 I는 다음과 같이 할 것 기능을 기반 뷰에서 generic create view
장고 양식
class TestCreateView(CreateView):
form_class = TestCreateForm
##forms.py
class TestCreateForm(forms.ModelForm):
class Meta:
model = Test
def __init__(self, user, *args, **kwargs):
super(TestCreateForm).__init__(*args, **kwargs)
self.fields['test_field'] = Testing.objects.filter(user=user)
:
일반 클래스를 기반으로보기에 지금form = TestCreateForm(request.user)
내가 덮어 쓰기해야합니까 , get
및 post
방금이 방법이 필요하십니까?
당신은 체크 아웃해야 CCBV의 ['CreateView'] (http://ccbv.co.uk/CreateView/). 장고의 클래스 기반 뷰에서 사용할 수있는 것을 찾는 훌륭한 참고 자료입니다. 유용하다고 생각하길 바랍니다. * 전체 공개 :이 도구를 작성했습니다. * – meshy