Add DjangoFormInputObjectType to forms/types#1325
Merged
firaskafri merged 9 commits intoMay 24, 2023
Merged
Conversation
0121634 to
ab6c1bf
Compare
Collaborator
|
@ndpu Hello, sorry this took long |
Contributor
Author
|
@firaskafri hi, ok, will do |
Collaborator
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
Contributor
Author
|
@firaskafri fixed tests and pre-commit hook error. Should be ok now. (force-pushed rebased branch...) |
Collaborator
|
@ndpu would you also add your example to the docs please? |
Contributor
Author
|
@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... |
firaskafri
approved these changes
May 24, 2023
superlevure
pushed a commit
to loft-orbital/graphene-django
that referenced
this pull request
Jul 19, 2023
* 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 <[email protected]>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
DjangoFormInputObjectType(InputObjectTypederived 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_typeis specified inMeta) to dynamically convert enum values back.With
DjangoFormInputObjectTypewe 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: