Newb here, getting the following error:
need help debugging it.
I have the edit.html in a folder, with my base html but it cannot find it.
urls.py
from django.urls import path
from . import views
from django.contrib.auth import views as auth_views
urlpatterns = [
path(‘’,views.home,name=‘CMS-home’),
path(‘about/’,views.about,name=‘CMS-about’),
path(‘HHAProg/’,views.HHAProg,name=‘CMS-HHAProg’),
path(‘int:pk’, views.DetailView.as_view(),name=‘entry’),
path(‘submit’,views.CreateView.as_view(),name=‘submit’)
]
models.py
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.urls import reverse
class Post(models.Model):
title = models.CharField(max_length=100)
content = models.TextField()
date_posted = models.DateTimeField(default=timezone.now)
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title
class Estudiante(models.Model):
name = models.CharField(max_length=40,blank=False)
def str(self):
return self.name
class Programa(models.Model):
title = models.CharField(max_length=49,blank=False)
def str(self):
return self.title
class Casa(models.Model):
student = models.ForeignKey(Estudiante, on_delete=models.PROTECT)
cohort = models.ForeignKey(Programa, on_delete=models.PROTECT)
phoneNum = models.CharField(max_length=15,blank=False)
emailAddr = models.CharField(max_length=44,blank=False)
homeAddr = models.CharField(max_length=44,blank=False)
ciudad = models.CharField(max_length=25,blank=False)
estadio = models.CharField(max_length=3,blank=False)
zipC = models.CharField(max_length=10,blank=False)
def str(self):
return self.title
def get_absolute_url(self):
return reverse(‘entry’,kwargs={‘pk’: self.pk})
views.py
from django.shortcuts import render,HttpResponse
from . import models
from . models import Post, Casa, Estudiante, Programa
from django.views.generic import ListView,DetailView,CreateView
from django.core.paginator import Paginator
Created views here.
def home(request):
context = {
‘posts’ : Post.objects.all()
}
return render(request,‘CMS/home.html’,context)
def about(request):
return render(request,‘CMS/about.html’,{‘title’: ‘About’})
def HHAProg(request):
return render(request,‘CMS/HHAProg.html’,{‘title’: ‘HHAProg’})
class IndexView(ListView):
context_object_name =‘casa’
template_name = ‘home.html’
def get_queryset(self):
return models.Casa.objects.all()
class DetailView(DetailView):
context_object_name =‘casa’
model=models.Casa
template_name = ‘entry.html’
class CreateView(CreateView):
model= models.Casa
fields = [‘student’,‘cohort’,‘phoneNum’,‘emailAddr’,‘homeAddr’,‘ciudad’,‘estadio’,‘zipC’]
template_name =‘edit.html’