-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DjangoFormInputObjectType to forms/types #1325
Add DjangoFormInputObjectType to forms/types #1325
Conversation
0121634
to
ab6c1bf
Compare
@ndpu Hello, sorry this took long |
@firaskafri hi, ok, will do |
Hello there! Any updates? |
InputObjectType derived class which gets fields from django form. Type of fields with choices (converted to enum) is set to custom scalar type (using Meta.object_type) to dynamically convert enum values back.
6ceba53
to
e90edc1
Compare
@firaskafri fixed tests and pre-commit hook error. Should be ok now. (force-pushed rebased branch...) |
@ndpu would you also add your example to the docs please? |
@firaskafri hi, docs added. I have an error with sphinx 1.5.3 and all is ok with latest version (7.0.0). I think docs/requirements.txt should be updated... |
* Add DjangoFormInputObjectType to forms/types InputObjectType derived class which gets fields from django form. Type of fields with choices (converted to enum) is set to custom scalar type (using Meta.object_type) to dynamically convert enum values back. * Correct Reporter model a_choice field type according to CHOICES tuple * Add tests for DjangoFormInputObjectType * Add pyenv files to .gitignore * Fix pyupgrade * Fix tests * Add docs * Fix docs example --------- Co-authored-by: Firas Kafri <3097061+firaskafri@users.noreply.github.com>
Adds
DjangoFormInputObjectType
(InputObjectType
derived class) which can retrieve fields from django form. Type of fields with choices (which was converted to enum automatically) is set to custom scalar type (ifobject_type
is specified inMeta
) to dynamically convert enum values back.With
DjangoFormInputObjectType
we can build input types with data from different models, nest it in one another etc. It's just like an ordinary input object type that have same fields as django form.Enum values converting feature can be convenient, please comment your thoughts about this.
Example: