dimanche 31 janvier 2021

404 error when running local host command: django, python

when running the local host command, I get a 404 error. I have defined the empty ' ' path but the only URL paths that work are the '/admin', /posts/', and '/posts/about'.

urls.py

from django.urls import path
from . import views

urlpatterns = [
path('', views.home, name='Posts-Home'),
path('about/', views.about, name='Posts-About'),

]

views.py

from django.shortcuts import render
from .models import verdict

posts1 =[
    {
        'author' : 'Tom E',
        'title' : 'review1',
        'content' : 'verdict1',
        'date_posted' : 'today',
    },
    {
        'author' : 'Adam K',
        'title' : 'review2',
        'content' : 'verdict2',
        'date_posted' : 'yesterday' 
    }
]


    # Create your views here. 
    def home(request):
        #puts data into dictionary
        context ={
            #postkey
            'reference' : verdict.objects.all()
        }
        return render(request, 'posts/home.html', context)
    
    
    def about(request):
         return  render(request, 'posts/about.html', {'title': 'about'})



Aucun commentaire:

Enregistrer un commentaire