我不知道如何引用我的OneToOne字段:
class Studente(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
ore = models.IntegerField()
在我的views.py文件中。
@login_required(login_url="/home/")
def vistaPrivata(request):
all_corsi = Corso.objects.all()
user = request.user
user_ore = [[ I Dont really know what to write in here ]]
template = loader.get_template('corsi/vistaPrivata.html')
if request.method == 'POST':
logout(request)
return redirect('Completa')
else:
context = {
'user_ore' = user_ore,
}
return HttpResponse(template.render(context, request))
能帮我吗? 任何帮助将不胜感激