Re: [Django] #7018: Make ModelForm multiple inheritance possible

2021-08-11 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  dev
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Mike Fogel):

 * cc: Mike Fogel (removed)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.a3aa2479a39d2dc227af11ad8d2dcc2e%40djangoproject.com.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2016-02-06 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by mitar):

 Now with Django 1.9, the approaches mentioned in this ticket do not work
 anymore, because get_declared_fields is not available anymore. What would
 be a new approach?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e3a920c592d9d017f6e050c881ed9d3e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-10-17 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by mjtamlyn):

 Sounds like you want something along the lines of
 https://github.com/bmispelon/django-multiform


 You'd nerd to write the connection logic yourself each time but I think
 that's fine. Personally I'm not convinced this is code which needs to live
 in core. Baptiste may have a different opinion.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.8164a36340c59f05bf1a122e90cd252f%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-10-17 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by anonymous):

 Replying to [comment:20 mjtamlyn]:
 > Worth noting here that you can now combine Form and ModelForm together.
 Combining the multiple models is a much more complex issue, and one I'm
 personally not convinced should be included. This has implications on
 validation and saving which could have a myriad of edge cases. Personally
 I think some code which renders and validates two forms would be superior,
 handled effectively as a nonhomogeneous Form set.
 This is closer to what I want to do (combine multiple model forms in one
 form)
 Where can I find info on this ?
 thanks,

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.002916615a33947f02b2c1cb4bcd53fe%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-10-17 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+

Comment (by mjtamlyn):

 Worth noting here that you can now combine Form and ModelForm together.
 Combining the multiple models is a much more complex issue, and one I'm
 personally not convinced should be included. This has implications on
 validation and saving which could have a myriad of edge cases. Personally
 I think some code which renders and validates two forms would be superior,
 handled effectively as a nonhomogeneous Form set.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.d77b1b3e07385400a19d9daf78960e23%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-10-17 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by maa@…):

 * cc: maa@… (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.9ef281339f5d50cd42326beb2a13e30e%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-07-30 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by Lance0312):

 * cc: cyen0312+django@… (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.86c7e195ccfc5b02da28a0c7ab173680%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #7018: Make ModelForm multiple inheritance possible

2013-01-18 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+
 Reporter:  bear330  |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Forms|  Version:  master
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+
Changes (by bouke):

 * cc: bouke (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #7018: Make ModelForm multiple inheritance possible

2011-09-11 Thread Django
#7018: Make ModelForm multiple inheritance possible
---+
   Reporter:  bear330  |  Owner:  nobody
   Type:  New feature  | Status:  new
  Milestone:   |  Component:  Forms
Version:  SVN  |   Severity:  Normal
 Resolution:   |   Keywords:
   Triage Stage:  Accepted |  Has patch:  0
Needs documentation:  0|Needs tests:  0
Patch needs improvement:  0|  Easy pickings:  0
  UI/UX:  0|
---+
Changes (by Alex):

 * stage:  Design decision needed => Accepted


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2011-08-30 Thread Django
#7018: Make ModelForm multiple inheritance possible
--+
   Reporter:  bear330 |  Owner:  nobody
   Type:  New feature | Status:  new
  Milestone:  |  Component:  Forms
Version:  SVN |   Severity:  Normal
 Resolution:  |   Keywords:
   Triage Stage:  Design decision needed  |  Has patch:  0
Needs documentation:  0   |Needs tests:  0
Patch needs improvement:  0   |  Easy pickings:  0
  UI/UX:  0   |
--+
Changes (by semente):

 * cc: semente+django@… (added)
 * ui_ux:   => 0
 * easy:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2011-04-05 Thread Django
#7018: Make ModelForm multiple inheritance possible
--+--
   Reporter:  bear330 |Owner:  nobody
   Type:  New feature |   Status:  new
  Milestone:  |Component:  Forms
Version:  SVN | Severity:  Normal
 Resolution:  | Keywords:
   Triage Stage:  Design decision needed  |Has patch:  0
Needs documentation:  0   |  Needs tests:  0
Patch needs improvement:  0   |
--+--
Changes (by tehfink ):

 * cc: djsnickles@… (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2011-03-26 Thread Django
#7018: Make ModelForm multiple inheritance possible
--+--
   Reporter:  bear330 |Owner:  nobody
 Status:  new |Milestone:
  Component:  Forms   |  Version:  SVN
 Resolution:  | Keywords:
   Triage Stage:  Design decision needed  |Has patch:  0
Needs documentation:  0   |  Needs tests:  0
Patch needs improvement:  0   |
--+--

Comment (by mitar):

 Have you tried my mixin above? It works for me for combining user,
 UserProfile and my UserSettings models into one form.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2011-03-26 Thread Django
#7018: Make ModelForm multiple inheritance possible
--+--
   Reporter:  bear330 |Owner:  nobody
 Status:  new |Milestone:
  Component:  Forms   |  Version:  SVN
 Resolution:  | Keywords:
   Triage Stage:  Design decision needed  |Has patch:  0
Needs documentation:  0   |  Needs tests:  0
Patch needs improvement:  0   |
--+--
Changes (by Ciantic):

 * cc: ciantic@… (added)


Comment:

 This is especially needed as the class based views does not support views
 with multiple forms.

 I have models and forms that are joined together with `ForeignKey` or
 `OneToOne`, e.g. I have models: `User`, `UserProfile`, `TwitterProfile`,
 `FacebookProfile`, but there is no easy way to write views, it would be
 handy if I could just simply combine the forms as one form.

 There is also requirement to combine formset and form in one view, e.g.
 billing view where `InvoiceForm` and `InvoiceRowFormset` should be joined.
 They do implement rather similar interface (save, clean, etc) but creating
 good class based views that support multiple forms in addition to formsets
 in one view needs more thinking.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2010-12-30 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+--
  Reporter:  bear330 | Owner:  nobody
Status:  new | Milestone:
 Component:  Forms   |   Version:  SVN   
Resolution:  |  Keywords:
 Stage:  Design decision needed  | Has_patch:  0 
Needs_docs:  0   |   Needs_tests:  0 
Needs_better_patch:  0   |  
-+--
Changes (by carbonXT):

 * cc: carbonXT (added)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #7018: Make ModelForm multiple inheritance possible

2010-07-21 Thread Django
#7018: Make ModelForm multiple inheritance possible
-+--
  Reporter:  bear330 | Owner:  nobody
Status:  new | Milestone:
 Component:  Forms   |   Version:  SVN   
Resolution:  |  Keywords:
 Stage:  Design decision needed  | Has_patch:  0 
Needs_docs:  0   |   Needs_tests:  0 
Needs_better_patch:  0   |  
-+--
Changes (by mitar):

  * summary:  Make ModelForm multiple inheritance is possible. => Make
  ModelForm multiple inheritance possible

Comment:

 I made a metaclass which allows multiple ModelForm forms to be combined. I
 also made a mixin which then allows resulting form to be used on multiple
 instances (for each parent ModelForm one) which are then used to populate
 form fields, validation and also they are all updated by simply calling
 `form.save()`. All this is heavily hackish but it works and it proves this
 is doable and could go also into official version (where it would be much
 less hackish). I am attaching the code.

 The problem is that it is hard to reason about such forms and code and
 even decide which behavior is proper (for example: how to order fields in
 a form with multiple parents and even with some manually declared fields?
 what if fields definitions overlap?). (It is useful to use
 FieldsetFormMixin described bellow to remedy this.)

 All this can be used with my [comment:ticket:6630:12 mixin for fieldsets]
 so that every parent form can be put into its own fieldset. Then it is
 possible to do such form which allows user and profile changes at the same
 time:

 {{{
 class UserAndProfileChangeForm(metaforms.FieldsetFormMixin,
 metaforms.ParentsIncludedModelFormMixin, UserChangeForm,
 UserProfileChangeForm):
   error_css_class = 'error'
   required_css_class = 'required'
   fieldset = UserChangeForm.fieldset + [(
 utils_text.capfirst(UserProfileChangeForm.Meta.model._meta.verbose_name),
 {
   'fields': UserProfileChangeForm.base_fields.keys(),
 })]

   __metaclass__ = metaforms.ParentsIncludedModelFormMetaclass
 }}}

 And save on such form validates and saves both objects. Ah, one more
 thing, form initialization changes somewhat. `instance` attribute gets a
 list of instances:

 {{{
 forms.UserAndProfileChangeForm(request.POST, instance=[request.user,
 request.user.get_profile()])
 }}}

 But be careful if you pass objects directly from request, those instances
 are changed by `form.is_valid` method even if form does not validate which
 could allow user to alter some context (post)processors behavior. So it is
 necessary to do something like:

 {{{
 if request.method == 'POST':
   stored_user = copy.copy(request.user)
   form = forms.UserAndProfileChangeForm(request.POST,
 instance=[request.user, request.user.get_profile()])
   if form.is_valid():
 objs = form.save()
 return shortcuts.redirect(objs[-1]) # The last element is user profile
 object
   else:
 # Restore user request object as it is changed by form.is_valid
 request.user = stored_user
 if hasattr(request.user, '_profile_cache'):
   # Invalidates profile cache
   delattr(request.user, '_profile_cache')
 else:
   form = forms.UserAndProfileChangeForm(instance=[request.user,
 request.user.get_profile()])
 }}}

 Also user registration form (for use with django-registration) is doable:

 {{{
 class UserRegistrationForm(metaforms.FieldsetFormMixin,
 metaforms.ParentsIncludedModelFormMixin, UserCreationForm,
 UserProfileChangeForm):
   error_css_class = 'error'
   required_css_class = 'required'
   fieldset = UserCreationForm.fieldset + [(
 utils_text.capfirst(UserProfileChangeForm.Meta.model._meta.verbose_name),
 {
   'fields': UserProfileChangeForm.base_fields.keys(),
 })]

   def save(self, commit=True):
 # We disable save method as registration backend module should take
 care of user and user
 # profile objects creation and we do not use this form for changing
 data
 assert False
 return None

   __metaclass__ = metaforms.ParentsIncludedModelFormMetaclass
 }}}

 With django-registration backend having such `register` method:

 {{{
 def register(self, request, **kwargs):
   user = super(ProfileBackend, self).register(request, **kwargs)
   profile, created =
 utils.get_profile_model().objects.get_or_create(user=user)

   # lambda-object to the rescue
   form = lambda: None
   form.cleaned_data = kwargs

   # First name, last name and e-mail address are stored in user object
   forms_models.construct_instance(form, user)
   user.save()

   # Other fields are stored in user profile object
   forms_models.construct_instance(form, profile)
   profile.save()

   return user
 }}}

-- 
Ticket URL: