이것은 내 models.py입니다
class Profile(models.Model):
name=models.CharField(max_length=30)
choices = (
('C', 'C'),
('C++', 'C++'),
('Java', 'Java'),
('Python', 'Python'),
)
intrest = models.CharField(max_length=6, choices=choices)
이것은 내 views.py입니다.
if request.method=="POST":
choice=request.POST['choice']
이 선택은 내 데이터베이스에 추가하려는 값이 있습니다.이 선택을 내 데이터베이스에 추가하는 방법은 무엇입니까?
이것이 도움이 될 기본 사항입니다. :)
from .models import Profile
def profile(request):
if request.method=="POST":
name = request.POST['name']
choice = request.POST['choice']
profile = Profile(name = name, choice = choice)
profile.save()
return render(request,"example.html")
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다