I want to add a contact form in my homepage in a mezzanine project. Homepage inherits from Page class and is loaded perfectly using the mezzanine project.
I created a new generic view in my project and I bound urls.py to it.
class Home(FormView):
template_name = "index.html"
form_class = ContactForm
success_url = '/'
def get_context_data(self, **kwargs):
page = Page.objects.get(title='Home')
return {
'page': page,
'params': kwargs,
}
If if load the page in a terminal, using django.test.client, I found exactly what I want in my homepage which is in page.homepage.
But the template index.html
is not loaded at all. I only get the base.html
. So variables based on {{ page }}
are not found. index.html
seems to be ignored.
Could you help me to find out what's going wrong there? How, for example, can I test the template index?
I don't know why the template wasn't load. The one returned was index.html
from mezzanine site-packages which is out of my understanding. So I give up the solution of rewriting a special view for my homepage.
Instead, the easiest way to rewrite a view using Mezzanine is using the page_processor. Then everything works fine. There is a solution here which explains it: