我创建了一个新帐户,当我尝试打开新表格时,显示为Page Not found
view.py
def Hfapplication(request):
user = request.GET.get("user_id", request.user.id)
print(user)
host_family = get_object_or_404(hfmodel, pk=user)
context = {'exists': True, 'existing_hfmodel': host_family}
if request.method=='GET':
form =Forms.HFForm(instance=host_family)
context['form']=form
return render(request, 'hfapplication.html', context)
print("hii")
elif request.method =='POST':
form = Forms.HFForm(data=request.POST, instance=host_family, files=request.FILES)
context['form']=form
if form.is_valid():
form.save()
submit = form.cleaned_data['submitted']
if submit:
context['msg]']= "submitted"
return render(request,"submittedApp.html", context)
context['msg]']= "saved"
return render(request, "submittedApp.html", context)
这是我遇到错误的观点
这是我的模特,我不确定为什么会出问题。我还通过删除主键进行了检查,但仍然存在相同的问题
class hfmodel(models.Model):
user = models.OneToOneField(User, db_column='user', related_name="host_family", on_delete=models.CASCADE, primary_key=True)
drop_down1 = models.CharField(max_length=300, choices=USER_DORPDOWN1, null=True, blank=True)
drop_down3 = models.CharField(max_length=300, choices=USER_DORPDOWN3, null=True, blank=True)
schoollist = models.CharField(max_length=300, choices=HF_School, null=True, blank=True)
namelocal = models.CharField(max_length=300, null=True, blank=True)
hfschool = models.CharField(max_length=300, null=True, blank=True)
#Host Father Informatin
hffn = models.CharField(max_length=300, null=True, blank=True)
hfln = models.CharField(max_length=300, null=True, blank=True)
birth_date1 = models.DateField(null=True, blank=True)
hfoccupation = models.CharField(max_length=300, null=True, blank=True)
hfemp = models.CharField(max_length=300, null=True, blank=True)
hfwph = models.CharField(max_length=300, null=True, blank=True)
hfcph = models.CharField(max_length=300, null=True, blank=True)
hfedu = models.CharField(max_length=300, null=True, blank=True)
hfemail = models.CharField(max_length=300, null=True, blank=True)
hfcrim = models.CharField(max_length=300, null=True, blank=True)
ethnicbckf = models.CharField(max_length=300, choices=USER_DORPDOWN5, null=True, blank=True)
ethnicbckf_other = models.CharField(max_length=300, null=True, default="", blank=True)
在此处输入代码