I am working on my first Django project and learning a lot along the way. So far, I have set up a very simple website and am having trouble with the next steps. Through this project, I am hoping to achieve a website that provides users with reliable resources based on how they answer the three questions they are asked.
Website Explanation: The user opens the website and is prompted to click a button to go to the first step. The first step asks the user to choose the subject they would like a resource on (for now, all of the listed subjects are related to cooking). Then, they choose their level of expertise (beginner, intermediate, advanced). Finally, they choose a preferred medium for their resource (article/blog, video, book). Based on the subject, their level of expertise, and their preferred medium, the last page will give the user a resource that is retrieved from a linked database.
Where I Am Stuck: So far, I have created five pages (home page, one page for each question, and a results page) and have set up the choices for each question. Now, I am having trouble finding a way to combine the user's three answers into one variable, which I will use to fetch data from a connected database and display the respective resources.
For reference, I have included code from my "views.py" file and "Subject Page" file (this page is Step 1 of the process where the user chooses a subject. The format for the other two questions is very similar to this one, which is why I only included the code for this page). If you are willing to help, please feel free to request any other references I may be able to provide. Also, though I am not yet at that step, I'm open to guidance on connecting my website to a database. As always, any help/guidance would be much appreciated! Thank you :)
views.py code:
from django.shortcuts import render
from django.http import HttpResponse
def HomePage(request):
return render(request, 'ResourceApp/HomePage.html')
def SubjectPage(request):
return render(request, 'ResourceApp/SubjectPage.html')
def LevelPage(request):
return render(request, 'ResourceApp/LevelPage.html')
def MediumPage(request):
return render(request, 'ResourceApp/MediumPage.html')
def ResultsPage(request):
return render(request, 'ResourceApp/ResultsPage.html')
Subject Page code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Subject | Tools For Fools</title>
</head>
<body>
<h1> Step 1 </h1>
<form action="http://127.0.0.1:8000/level/">
<label for="Subject">Choose a Subject:</label>
<select id="Subject" name="Subject">
<option value="Knife Skills">Knife Skills</option>
<option value="Culinary Terms">Culinary Terms</option>
<option value="Recipes">Recipes</option>
</select>
<input type="Submit">
</form>
</body>
</html>