📜  django 从数据库中填充表单 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:26.955000             🧑  作者: Mango

代码示例1
from django.forms.models import model_to_dict

def view(request):
    game = Game.objects.get(id=1)
    form = UserQueueForm(initial=model_to_dict(game))
    return render_to_response('my_template.html', {'form': form})