请帮助..我不知道我该做什么代码才能工作..
home.html的:
input_ABCD_company_12345678.tsv: pass
input_CompanyTooLong_company_12345678.tsv: fail
input_Company_company_12345678901.tsv: fail
urls.py:
<form class="subscribe-form" action="{% url 'subscribe' %}" method="POST">{% csrf_token %}
{{ form }}
<button class="btn btn-main btn-lg" type="submit">Подписаться!</button>
</form>
{% if success %}
<div class="subscribe-result">
{{ success }}
</div>
{% endif %}
models.py:
url(r'^$', 'interior_app.views.home', name='home'),
url(r'^subscribe/$', 'interior_app.views.subscribe', name='subscribe')
forms.py:
class Subscriber(models.Model):
email = models.EmailField('', max_length=100, null=True, blank=True)
admin.py:
class SubscriberForm(forms.ModelForm):
class Meta:
model = Subscriber
fields = ['email']
views.py:
class SubscriberAdmin(admin.ModelAdmin):
list_display = ('email',)
admin.site.register(Subscriber, SubscriberAdmin)
我在表单中输入电子邮件,按钮,没有任何事情发生。 admin中的任何数据,任何{{success}}。
我不需要AJAX ..我只想用Django
来做这个功能