name - value : 한쌍
<input type="text" name="my_id" value="travel"> 선택
<input type="text" name="my_id" value="holiday"> 선택
<input type="text" name="my_id" value="choosuck">
print(req.POST.get("my_id") ) ====> travel
print(req.POST.getlist("my_id") ) ====> [ "travle" , "holiday" ]
하나만 뽑고싶으면 for문으로 돌려서 뽑기
<form action="" method="post">
{% for obj in objects %}
<input id="selected" type="checkbox" name="selected" value="{{ obj.id }}">
{% endfor %}
<button type="submit">저장</button>
</form>
def checkbox_result(req):
rec = req.POST.getlist('my_id')
print(req.POST.getlist("my_id"))
return render( req, 'checkbox_result.html', { 'checkbox' : req.POST.getlist('my_id'), 'abc' : rec[0] } )
#html
{% for check in checkbox %}
{{ check }}
{% endfor %}
{{ abc }}
외래키가 불러오는건 member의 id만 참고하지만 불르면 member 오브젝트를 통으로 부른다고 이해한게 맞죠?
영우님 한 거처럼 모델을 여러개 만들어서 참조하는 게 방법일 수도 있겠네요
https://github.com/django-ckeditor/django-ckeditor
삽질 필요다..
python3 manage.py collectstatic