There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I am currently on step 15 of Introduction to Django - Fortune Teller
It states that I should be seeing fortune.html as my homepage once I save the file, but it is currently displaying the default installation success page for Django.
Here is what my views.py, urls.py, and fortune.html files look like respectively.
from django.shortcuts import render
# Create your views here.
def fortune(request):
return render(request, 'randomfortune/fortune.html')
from django.urls import include, path
from . import views
urlpatterns = [
path("", views.fortune()),
path("", include("randomfortune.urls"))
]
<!DOCTYPE html>
<html lang="en">
<head>
<title>Django Fortune Teller</title>
<style>
body {
text-align: center;
}
</style>
</head>
<body>
<h1>Here is your fortune:</h1>
<p>Place holder for fortune</p>
</body>
</html>
Any guidance on where I’m going wrong would be much appreciated.
Hi!! Maybe you should check the project folder “fortune teller”, the file urls.py should looks like this:
"""fortuneteller URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path("", include('randomfortune.urls'))
]
For your app “randomfortune”, urls.py, should looks like this:
from django.urls import path
from . import views
urlpatterns = [
path("", views.fortune)
]
For “randomfortune” you have to create the file urls.py, is not a default file as in the case of fortuneteller. Hope this help you. Saludos
Hi. Driving me nuts…for days now. Got stuck on ‘point 15’ in Fortuneteller django app. I even erased whole progress to start all over, followed then every step from the tutorial video in ‘get unstuck’ section, every single step done EXACTLY like the tutor…and while his app runs in point 15, mine is giving me this ■■■■ again: 'no module named ‘‘django.contribclear’’ ’ Help please! cause I’m losing it altogether
Hi. Noone knows? That’s sad as there’ s nowhere else I can turn. Have tried to google out this exact thing but no success. So AGAIN I have reset the whole project and gone through the first 14 tasks. This time, in task 15, I am getting another error message:
can’t open. no ‘manage.py’ found
The website is robust and may hold a ton of value. But I’m getting fed up with it as it’s just not possible to be getting two different outputs for writing EXACTLY same two inputs (first 14 tasks), can it? (I have even checked the ‘hints’ and copied from those).
Time is running, and this little project for one afternoon had got me STUCK for two weeks now. and no help around whatsoever. Aah
I’ve found the solution to this issue, although this was originally posted a while ago so I figure (and hope) you’ve moved on. Having said that, it might help someone else searching the forums for a solution.
First of all, for the ‘no manage.py found’ issue I’ve crossed off my current terminal session and started a new one (where it says bash). This seemed to do the trick as ‘cd fortuneteller’ allowed me to access that folder.
After being able to run ‘python3 manage.py runserver 0.0.0.0:4001’ successfully there was still an error on the browser. I solved this by going into randomfortune/views.py and adding ‘render’ to the function.
i.e. def fortune(request):
return render(request, “randomfortune/fortune.html”)
I only mention this because it’s not specified in the hints and I completely missed it the first time around.
Under Creating Your First Django App In the Introduction to Django Section There is an instruction to create the vetoffice using the startapp command. After you input the command nothing is outputted. The instructions say to add “vetoffice.apps.VetofficeConfig” to the INSTALLED_APPS list. My question is this… where did they get “vetoffice.apps.VetofficeConfig” from?
Using a View to Send an HTML file.
The instruction is to create a hierarchy vetoffice/templates/vetoffice.
I am stuck on trying to create another folder from the templates folder. When you right click, it doesn’t have an option to create a folder, only to delete or rename the file. What am I doing wrong? Right-clicking on vetoffice was no problem.