django populate form from database

Solutions on MaxInterview for django populate form from database by the best coders in the world

showing results for - "django populate form from database"
Benjamín
06 Jan 2019
1from django.forms.models import model_to_dict
2
3def view(request):
4    game = Game.objects.get(id=1)
5    form = UserQueueForm(initial=model_to_dict(game))
6    return render_to_response('my_template.html', {'form': form})