I’m stuck. I’m following the Poll tutorial but I get stuck at the start. I can’t see the Polls view. I can follow the tutorial up the polls view. (Python 3.8.2 Django 3.0.6 Windows 10 Home 64 bit
I have to run server on port 8010 and when I run the browser to see the polls I get
command line:
Quit the server with CTRL-BREAK.
Not Found: /polls
[17/May/2020 00:10:33] “GET /polls HTTP/1.1” 404 1954
or (/polls/ vs /polls)
Not Found: /polls/
[17/May/2020 00:28:35] “GET /polls/ HTTP/1.1” 404 1957
Using the URLconf defined in mysite.urls , Django tried these URL patterns, in this order:
admin/
The current path, polls/ , didn’t match any of these.
I can’t find the problem and this is the second time I try the tutorial. The first time I got stuck I went to Mozilla to run the tutorial (Django Version 2,1) and I went farther until I got stuck, so I’m coming back to this tutorial.
I have to run on port 8010 because 8005 is still used by the Mozilla tutorial and port 8000 is run by a local file ( I ran Python -m http.server to test it so I can’t use it anymore)
So, how do I free the 8000 port to run new apps? Is this causing my problems?
Found my first mistake: I modified the file mysite/urls.py instead of mysite/mysite.py. Also I can use Localhost:8000/polls but localhost:8000 still shows my first test page (a picture)
Please post the contents of your urls.py file - that is where your urls are to be defined. (Include both your mysite/urls.py and your polls/urls.py. There is no mysite/mysite.py file in that tutorial.)
(When posting source code, please include it between lines containing three backticks (`) characters. In other words, you’ll have one line with only ```, then your source code, then another line with ```)
Ok, so the next two things we need to confirm is your ROOT_URLCONF in your settings is correct, and confirm that you don’t have a different urls.py file in your project that is being referenced.
Assuming your base directory is “mysite”, your ROOT_URLCONF would be ‘mysite.urls’, and you should have a file urls.py in your mysite/polls directory.
Thank you! I finished all the basic tutorials and how to write reusable apps. Any book, class or website besides Django Documents recommended for improving Django skills?
And (shameless plug), I write a lot about Django, podcast about learning the framework, and stream on Twitch regularly to show Django development. mattlayman.com is the place to learn more about what I do.
In addition to @mblayman’s answer (with whom I agree 100% on this - those are all excellent suggestions), the awesome-django repository on github has a good list under the Resources section.
There’s another regular here - Adam Johnson, whose blog is worth reading.
In general Python terms, Trey Hunner’sPython Morsels is worth a look. In his blog posts he takes the time to do an in-depth look at different features or characteristics of Python. The morsels are a curated set of exercises to help you really understand what you’re doing with it.
In general, it’s worth following the blogs and other writings of the active people within the Django community.
You could start by looking at the Organizers pages from the last couple of DjangoCons - you’ll see underneath some of the names a “globe” icon, indicating a link to their web sites. It’s also worth looking at the sponsors listing as well - those are the companies that are usually using Django on a regular basis, and may have blogs with django-related materials as well.
Some of the sponsors are more Django-oriented than others, but most have blogs that contain interesting and/or useful information.
(I’m going to avoid identifying any specific company blogs, because I’ve had the pleasure of meeting a lot of people in this business over the years and really don’t want to insult anyone by forgetting to include them in any list I would post here.)
I solve mine by modifying mysite/mysite/urls.py wich even contain a part of the code to which you just have to add ‘import include…’ and ‘path(‘polls/’…’
… and not mysite/urls.py which is originaly empty of any code.
Hope you succeed!
I have considered all the suggestions, but still, I am facing this problem. I modified the file mysite/mysite/urls.py. But still I am facing this issue and I got stuck
After a couple agonizing and frustrating hours it worked without any edits to any files. I manually CONTOL-C umpteen times and CMD-R the browser to death and to no avail as something similar seemed to happen previously. I even ps -ax and killed a couple runservers, nada.
I’m leaning towards a browser cache as unlikely as that maybe. But after a few runserver restarts it magically functioned as expected.