-
Notifications
You must be signed in to change notification settings - Fork 173
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 form_kwargs and get_form_kwargs for inline forms for solving issue #256 #257
Conversation
Thanks for the contribution! Strange that What version of Django are you using? |
Ah, sorry I misunderstood in my previous response that the get_formset_kwargs wasn't working for you. I see now that you're adding a more user friendly way to do this. I'll take a look over the changes and get back with any comments. |
Thank you @sdolemelipone for your quick response. The change made are working just fine in my project. How can I check the testings locally to improve the formatting for black and other failed tests ? |
This is the django and python versions that I am using: Django Version: 4.1.4
Python Version: 3.8.8 |
We should really add a pip install black flake8 isort Then run each of the below from the root directory of the project black . isort . flake8 . That will either fix the errors or tell you what needs fixing. |
Hi @dw-liedji, I agree that having the It's important that the old method of using After that could you add tests and documentation for the new You can run tests by running Don't worry about the failing python 3.5 / 3.6 tests, I think we need to remove those outdated versions from the test suite. I'll raise a separate PR for that. Let me know if you need any more help/advice with all that. |
Hi @sdolemelipone and happy new year! Thank you for your guide in testings. I would do it and make another push request. Concerning yours questions:
|
Hi @sdolemelipone , I have added a new commit. Please consider checking it out. |
Hi @dw-liedji, Please stick to using the same branch and pull request rather than creating new ones for further changes. That allows us to keep the changes in one place. Can you push your latest changes to the branch I am happy to review any tests and documentation that you submit. If you aren't sure where to start, I can point you in the right direction after you have pushed your latest changes to this branch. Alternatively I'm happy to write tests/docs if you don't have time. Thanks |
Closed, replaced with #271. |
Using this Stack Overflow answer and this section of the Django documentation, I have solve the issue of missing
form_kwargs
as attribute of theformset_kwargs
dictionary as mentioned in this section of the django-extra-views docs .To make the process of passing parameter to inline forms more easier and consistent, I have additionally added the
form_kwargs
and theget_form_kwargs
for passing parameters into each inline forms at runtime or not.With these changes, to change the arguments which are passed into each form within the formset, two options are now available:
form_kwargs
argument passed in to the FormSet constructor as previously mentionned in the documentation (I have solved the bug issue);form_kwargs
option in the inline formset class or override theget_form_kwargs
for passing parameters of inline forms at runtime.Here are some examples of using these news features. Note that, I use a fake Attribute class for the demonstration in theses examples, where the current user is passed into each inline forms:
Or override the
get_form_kwargs
for passing parameters of inline forms at runtime:It is important to note that it can still be done using the
get_formset_kwargs
interface see docs. However, theform_kwargs
declaration andget_form_kwargs
interface are just more easier and consistent.Thanks,
D. W. Liedji