[Fixed]-Getting error 404 in django framework python

1👍

Your URLs are currently set up for:

127.0.0.1:8000/myapp/
127.0.0.1:8000/myapp/list/
127.0.0.1:8000/admin

127.0.0.1:8000/ doesn’t have a URL set up – based on this SO answer you can create an index page like so:

from django.views.generic.base import TemplateView

    urlpatterns = [
            url(r'^myapp/', include('myapp.urls')),
            url(r'^admin/', include(admin.site.urls)),
            url(r'^$', TemplateView.as_view(template_name='myapp/index.html'),
            name='home'),
    ]

or just direct your browser to one of those URLs first listed.

Update: Looks like you’re also missing your Templates settings, add the following to your settings.py if it’s not currently there.

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

Django URLs can be a bit tricky to get the hang of – you may want to read the documentation on them

Leave a comment