亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用超鏈接更改 Django 中的實例?

如何使用超鏈接更改 Django 中的實例?

海綿寶寶撒 2021-11-09 10:56:23
我有 Django 的問題。我想使用超鏈接更改模型的特定字段,但我不知道該怎么做。我試過這個,但它什么也沒做。視圖.py:def sGiocatore(request, giocatore_id):    item = get_object_or_404(Giocatore, pk=giocatore_id)    item.fantasquadra=None #or something else    return redirect('/sondaggio/fantasquadre')網址.py:path('svincola/<int:giocatore_id>/', views.sGiocatore, name='s_player'),表格.py:class EditGiocatoreForm(forms.ModelForm):class Meta:    model = Giocatore    fields = ['fantasquadra']列表.html:{% for fantasquadra in elenco_fantasquadre %}<p><b>{{ fantasquadra.nome_fantasquadra }}:</b></p><table id="customers">{%for giocatore in elenco_giocatori%}{% if giocatore.fantasquadra.nome_fantasquadra == fantasquadra.nome_fantasquadra %}<tr><th>Nome</th><th>Cognome</th><th>N° Maglia</th><th>Squadra</th> <th>Ruolo</th><th>Svincola</th></tr><tr><td>{{ giocatore.nome_giocatore }}</td><td>{{ giocatore.cognome_giocatore }}</td><td>{{giocatore.numero_maglia}}</td><td>{{giocatore.squadra.nome_squadra}}</td><td>{{giocatore.ruolo.ruolo}}</td><td><a href="/sondaggio/svincola/{{giocatore.id}}">Svincola</a></td></tr> {% endif %}{% endfor %}</table>  {% endfor %}
查看完整描述

1 回答

?
犯罪嫌疑人X

TA貢獻2080條經驗 獲得超4個贊

item.save()修改后添加。


查看完整回答
反對 回復 2021-11-09
  • 1 回答
  • 0 關注
  • 185 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號