Changes between Initial Version and Version 1 of Ticket #34937


Ignore:
Timestamp:
Oct 30, 2023, 4:21:50 AM (11 months ago)
Author:
Willem Van Onsem
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34937 – Description

    initial v1  
    33In understand that renaming `get_form` to `get_formclass` will likely break ''a lot'',  so that is not an option, but we can define a `get_form_kwargs` which does not exists up till now, and then use this to generate optionally extra kwargs that are then injected when we *use* the form, so something like:
    44
    5 ```
     5{{{
    66ModelForm = self.get_form(
    77    request, obj, change=not add, fields=flatten_fieldsets(fieldsets)
     
    1111
    1212form = ModelForm(request.POST, request.FILES, instance=obj, **self.get_form_kwargs(request))
    13 ```
     13}}}
    1414
    1515in the `_chageform_view` for example. This makes it easy to inject for example the logged in user into the form, which is often done to limit the form fields.
Back to Top