当我单击提交按钮时,我想将模板中的下拉变量传递给函数
#models.py :-
class donnee(models.Model):
name = models.CharField(_('name'), max_length= 150)
def __unicode__(self):
return self.name
class Meta:
verbose_name = _('donnee')
verbose_name_plural = _('donnees filtrage')
ordering = ['name']
class Property(models.Model):
name = models.CharField(_('name'), max_length=50)
description = models.TextField(_('description'), blank=True)
def __unicode__(self):
return self.name
class Meta:
verbose_name = _('property')
verbose_name_plural = _('properties')
ordering = ['name']
class Physic2(models.Model):
name = models.ForeignKey(Property, verbose_name=_('name'), null=True, blank=True)
lapropriete = models.ForeignKey(donnee, verbose_name=_('lapropriete'), blank=True)
#lapropriete = models.CharField(_('property'), max_length=100)
description = models.TextField(_('description'), blank=True)
def __unicode__(self):
return self.lapropriete
class Meta:
verbose_name = _('physic2')
verbose_name_plural = _('physics2')
ordering = ['name']
#forms.py:-
class Physic2Form(forms.ModelForm):
class Meta:
model = Physic2
#views.py:-
def get_materials_one(request, category_slug=None):
if category_slug is None:
lafamille= 'general'
propriete= Physic2Form()
return render_to_response('material/critere1.html',
{'unefamille': lafamille,
'propriete': propriete},
context_instance=RequestContext(request))
#template:-
<form id= "testjson" action="{% url chercher_filtre1 %}" method= "get" onsubmit = "">
{{ propriete.lapropriete }}
<td><input type="submit" style="background-color:#D7D8D4;" value="Search" id= "chercher"/></td>
</div>
</form>
#function:-
valT1 = request.GET['lapropriete']
this don't work
当我单击下拉列表中的字段时
valT1 = 1 或 2...这只是字段的 id
我有田野
维氏硬度 (GPa) 剪切模量 (GPa) 杨氏模量 (GPa)
request.GET[??]