我想在我的django传单表格中有一个搜索框 我的模型是:
class Post(models.Model):
title = models.CharField(max_length=50)
location = models.PointField(null=True, blank=True)
objects = GeoManager()
def __str__(self):
return self.title
我的表单是:
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ('title','location')
widgets = {'location':Leafletwidget( attr=
{'settings_overrides':{ 'DEAFULT_CENTER':(35.68,51.38),
}
})
}
我的模板是:
{% load static %}
{% load leaflet_tags %}
{% load widget_tweaks %}
<div class="form-group">
{% render_ field form.location %}
</div>
<script type="text/javascript">
{% leaflet_js plugins="ALL" %}
</script>
我也不想像{{form}}那样渲染整个表格,而我想渲染
的每一个。提交如下:{%render_ field form.location%}