0

Right, is there any particular valid reason as to why - despite me doing everything correctly - do I get the error 404 message when I deploy my development server (on port 8000) from PyCharm?

This is the tutorial I am following Youtube Tutorial which I have followed to the letter. Why does it work for him and not for me?

I have confirmation the services has started. I have started this y using the following command

python manage.py runserver

Why is is that when setting my URL paths in the /urls config file on Django framework, does the browser just decide not to bother to actually read the file?

  • I have tried changing the port number in the settings on the PyCharm app - but what would have been way too simple.
  • I have tried closing down the app then starting it back up - of course that didn't work because that would have made my life way too easy
  • I've tried Googling the problem, it suggested the above

Here is my code below, first first snippet is apparently where the problem lies according to the browser. They're in separate files:

#Filename: pyshop/urls.py
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('products/', include('products.urls'))
]

from django.urls import path
from . import views


urlpatterns = [
path('', views.index)
]

from django.http import HttpResponse
from django.shortcuts import render


def index(request):
return HttpResponse('Hello World')

You will see its not my code. So what is it? And how do I get rid of the 404 problem?

Error 404 message

3
  • Are you using some type of plugin with Django? That plugin might be the problem, because it looks like that is handling things - pyshop/urls.py sounds like it's a predefined plugin, etc. and Django is not set properly with actual URLs or is being taken over by this plugin. Commented Sep 14, 2023 at 20:15
  • The only plugin is the installation of Dhango 4.2 - that is a file I created. Commented Sep 15, 2023 at 7:55
  • Re you edit: Did you maybe add a file with an additional URL specification, but did not configure Django to actually load that applications URLs? It is unclear what is which file, and why you believe both are consulted for paths at the same level.
    – anx
    Commented Sep 15, 2023 at 22:42

1 Answer 1

1

The URL http://example.com/ (that is an empty path!) matches neither the prefix admin/ nor the prefix admin/.

Append either prefix to the URL you are attempting to open (e.g. try openinig http://example.com/admin/), or add a new entry in your urlpatterns about where the empty URL should point/redirect to.

2
  • @Hunktydunkaty nuke browser cache? Usually caching is a problem on browsers. Commented Sep 15, 2023 at 16:02
  • @anx that is exactly what I have done. Commented Sep 15, 2023 at 21:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .