-2
我有一個領域是自定義標籤。使用Django taggit輸出的是標記insted name的標識。如何將輸出更改爲標記名稱?
當我從模型中獲得該特定字段並嘗試打印該字段中的所有存儲值時,它將顯示爲每個值的Id。
我怎樣才能得到我存儲爲字符串的值。
views.py
def patfirst(request): if request.method == "GET": return render(request, 'personal/patfirst.html') if request.POST.get('Next'): newSymp = request.POST.get('newSymptom') didata = Disease.objects.all().values_list('symptoms') args = {'newSymp' : newSymp,'didata':didata} return render(request, 'personal/patfirst.html',args)
models.py
class TaggedSymptoms(TaggedItemBase): content_object = models.ForeignKey("Disease") class Disease(models.Model): did = models.AutoField(verbose_name='Disease Id', primary_key=True,default=0) dName = models.CharField(max_length=100) symptoms = TaggableManager(verbose_name='symptoms list', through=TaggedSymptoms) symptoms.rel.related_name = "+"
patfirst.html
<h1>search disease</h1> <form method="post" action="#"> {% csrf_token %} Enter Symptom: <input type="text" name="newSymptom"/><br><br> <h3> {% for s in didata %} {{ s }} {% endfor %} </h3> <input type="submit" value="Next" name="Next"/> <input type="submit" value="None of these" name="NoneOfThese"/> </form>
碼?輸入?預期的產出? – schwobaseggl
輸入:任何症狀。例如:發燒和輸出:所有症狀列表將被採取,其疾病包含發熱症狀。例如:登革熱的症狀包括(發燒,頭痛,關節痛)和流感(發燒,肌肉痠痛,頭痛)。因此,登革熱和流感將顯示爲輸出。 –