Created
September 18, 2015 14:15
-
-
Save kezabelle/c841c049dcf4aafd5556 to your computer and use it in GitHub Desktop.
For joshuajonah in #django IRC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from django.forms import Form | |
>>> from django.contrib.auth import get_user_model | |
>>> from django.forms.models import ModelMultipleChoiceField | |
>>> class MyForm(Form): | |
>>> field = ModelMultipleChoiceField(queryset=get_user_model().objects.all()) | |
>>> myform = MyForm(initial={'field': [1]}) | |
>>> myform.as_p() | |
# this should include | |
# <select multiple="multiple" id="id_field" name="field">\n<option value="1" selected="selected">kezabelle</option> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment