Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django populate form from database

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})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #populate #form #database
ADD COMMENT
Topic
Name
6+9 =