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
Nested Formsets #6
Comments
I've not tried it, but it should work in theory. I've tried to mimic the API of Django's existing class-based views as closely as possible. So if you've defined a custom formset class as in your example you can do something like: EditBlockBuildingsView(InlineFormSetView):
formset_class = BaseBuildingFormset
model = models.Block
inline_model = models.Building
extra = 1
template_name = 'rentals/edit_buildings.html' In the template context you should have 'object' and 'formset' to play with. |
So you're saying I would still have to code up BaseBuildingFormset? I was hoping there was a way to have to use inline formsets and have an "inline inline" or a "formset of formsets" just using the code that already exists. Do you think that would work or would it still require all the custom code that blog talks about? |
Closing this because I ended up figuring it out. Basically, the answer is "yes, I do have to code up a custom BaseBuildingFormset to make this work." |
@auzigog mind showing the rest of us how to do it? |
@oppianmatt I have opened a StackOverflow question requesting an explanation on how to achieve this. |
Hi @blanchardjeremy |
@yerycs Unfortunately, I can't. Haven't engaged with Django in a decade. Sorry! |
I see, that's okay. @blanchardjeremy |
Hey guys, I was able to figure this out! I used https://github.com/philgyford/django-nested-inline-formsets-example/tree/main for heavy inspiration. In my example, I'm building a golf score tracking app. TeeTime This may not be the most efficient way, but it was a way I was able to replicate the github listed above. Two major areas of trouble I ran into.
Red is GolfRound I'm going to try and do this for the UpdateInlinesView, as I would really like to use that. Will update if there are differences there |
Got this to work for UpdateView. I just had to play around with the forms and formsets for the view:
|
Is it possible to do nested formsets with django-extra-views? I'm thinking of something along these lines: http://yergler.net/blog/2009/09/27/nested-formsets-with-django/ ... If it is possible, how would I do it?
A secondary question: Is it possible to have a formset with nested forms? So I have a formset of Survey objects and I want each to also render/save/update a related model of
The text was updated successfully, but these errors were encountered: