我正在尝试将包含联系表单的contact.html扩展到我的'home.html',作为base.html。但它不起作用,我尝试了许多方法,但没有工作。基本上,这个形式没有出现在home.html上。但是,它通常出现在localhost:8000 / contact上。 我的代码如下。
Home.html中
<section id="contact-us" class="section">
<div class="main-contact">
<div class="col-xs-6 col-lg-4">
<div class="contact">
<h2>LET US HELP YOU</h2>
<p> Push the boundaries of efficiency and excellence through game changing solutions.<br>
We provide innovative solutions that combine international best practices with cutting edge technology for finaciers, governments and property professionals.<br>
Speak to us or email us at info@resolutions.com.my today about how we can help your organisation get ahead.</p>
</div>
</div>
<div class="form">
<h3>FILL UP THE FORM BELOW FOR MORE INFORMATION ABOUT VALUATION MANAGEMENT SYSTEM</h3>
<div id="active">
<li><a href='{% url "contact.html" %}'></a></li>
{% block content %}
{% endblock %}
</div>
</a></li>
</div>
</div>
</section>
contact.html
{% extends "home.html" %}
{% load envelope_tags %}
{% block default-active %}active{% endblock %}
{% block content %}
<form action="{% url 'envelope-contact' %}" method="post">
{% csrf_token %}
{% antispam_fields %}
{{ form.as_p }}
<input type="submit" value="Send!" />
</form>
{% endblock %}
添加了我的views.py
from django.core.mail import send_mail, BadHeaderError
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from re_web.forms import ContactForm
# Create your views here.
from django.views.generic import (
TemplateView,
CreateView,
UpdateView,
DeleteView,
ListView,
DetailView,
)
from django.core.urlresolvers import reverse
from re_web.models import Article
class HomeView(TemplateView):
template_name = 'home.html'
def contact(request):
form_class = ContactForm
return render(request, 'contact.html', {
'form': form_class,
}
)