Getting this error when submitting the form associated with this view. Not sure what exactly is the problem, considering I have a form with a very similar structure and it works
Hey all I used the new path()
function and here is my working example that I'm sure will help:
views.py:
from django.views.generic.detail import DetailView
class ContentAmpView(DetailView):
model = Content
template_name = 'content_amp.html' # Defaults to content_detail.html
urls.py:
from django.urls import path
from .views import ContentAmpView
# My pk is a string so using a slug converter here intead of int
urlpatterns = [
path('/amp', ContentAmpView.as_view(), name='content-amp'),
]
templates/content_amp.html
Hello, AMPs
Welcome to AMP - {{ object.pk }}
{{ object.titles.main }}
Reporter: {{ object.reporter }}
Date: {{ object.created_at|date }}
Also note that in my settings.py
, under TEMPLATES
, I have 'APP_DIRS': True
. More on path here.