Re: [Django] #22609: Allow specifying the form field when instantiating a model field

2014-05-13 Thread Django
#22609: Allow specifying the form field when instantiating a model field
---+--
 Reporter:  django@…   |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.6
 Severity:  Normal |   Resolution:  wontfix
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by django@…):

 OK, I agree that coupling models/forms isn't great (even though modelForm
 and models are already coupled right?)

 I've come across quite a few limitations with subclassing/extending forms
 from models today so it's definitely something to discuss. 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/078.0f690ecd7bc67df884133d1a0210dc57%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22609: Allow specifying the form field when instantiating a model field

2014-05-13 Thread Django
#22609: Allow specifying the form field when instantiating a model field
---+--
 Reporter:  django@…   |Owner:  nobody
 Type:  Uncategorized  |   Status:  closed
Component:  Uncategorized  |  Version:  1.6
 Severity:  Normal |   Resolution:  wontfix
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by timo):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 I don't think the idea of specifying a form field on the model is going to
 fly since we don't want to add coupling like that between models and
 forms.

 Consider using
 `label=MyModel._meta.get_field('home_delivery').verbose_name` to make it
 more DRY.

 I don't think pulling unspecified kwargs from the model would be backwards
 compatible as you might have options changing on existing model form
 fields that are redefined on the form.

 I'm not saying the current situation is great, but I don't see a viable
 solution proposed here. Feel free to start a discussion on django-
 developers if you'd like to continue the discussion on how this can be
 improved.

-- 
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/078.463241cd8c56b44b53a954c019dd9f76%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22609: Allow specifying the form field when instantiating a model field

2014-05-10 Thread Django
#22609: Allow specifying the form field when instantiating a model field
---+--
 Reporter:  django@…   |Owner:  nobody
 Type:  Uncategorized  |   Status:  new
Component:  Uncategorized  |  Version:  1.6
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by django@…):

 An even more annoying case I've come across now is where I just want to
 change the `empty_label` for a `ForeignKey` field. I have to go all the
 way and create a new `form.ModelChoiceField`, redefine the queryset, etc.
 etc. just so I can specify an empty label:


 {{{
 models.py
 class MyModel:
 ...
  pickup_point = models.ForeignKey(PickupPoint, verbose_name="Pickup
 Point", blank=True, help_text="The Pickup Point to collect your box
 from.", null=True, related_name="box_orders")

 forms.py
 class MyModelForm:
 ...
  pickup_point =
 forms.ModelChoiceField(queryset=PickupPoint.objects.all().order_by('name'),
 empty_label="Select a pickup point", label="Pickup Point")

 }}}

 P.S. apologies for the multiple replies.

-- 
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/078.de63e8a19cb4de3506bb5e6a82ff1d7c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #22609: Allow specifying the form field when instantiating a model field

2014-05-10 Thread Django
#22609: Allow specifying the form field when instantiating a model field
---+--
 Reporter:  django@…   |Owner:  nobody
 Type:  Uncategorized  |   Status:  new
Component:  Uncategorized  |  Version:  1.6
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Unreviewed
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by django@…):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Perhaps another solution would be:

 when creating the new form field, pull the unspecified kwargs from the
 model-created form field.
 So: in MyModelForm, I wouldn't specify `choices` or `label`, and
 form.ModelForm would know to look at the auto-generated form for these
 values (if it can find them)

-- 
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/078.3a1387f6c980e3cc2e4bf4eca34d4cbd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #22609: Allow specifying the form field when instantiating a model field

2014-05-10 Thread Django
#22609: Allow specifying the form field when instantiating a model field
---+
 Reporter:  django@…   |  Owner:  nobody
 Type:  Uncategorized  | Status:  new
Component:  Uncategorized  |Version:  1.6
 Severity:  Normal |   Keywords:
 Triage Stage:  Unreviewed |  Has patch:  0
Easy pickings:  0  |  UI/UX:  0
---+
 I find myself having to do this time and time again, which really isn't
 DRY and won't be good for someone looking at my code in the future:


 {{{
 models.py

 class MyModel(models.Model):
 HOME_DELIVERY = (
 (True, _(u"Home Delivery)),
 (False, _(u"Pickup (free)")),
 )
 home_delivery = models.BooleanField(verbose_name="Pickup/Home
 Delivery",
  choices=HOME_DELIVERY,
 help_text="Something.", blank=False)

 forms.py

 class MyModelForm(forms.ModelForm):
  class Meta:
   model = MyModel

  home_delivery = forms.ChoiceField(empty_label=None,
 choices=MyModel.HOME_DELIVERY,
   widget=forms.RadioSelect(),
 label="Pickup/Home Delivery")
 }}}

 In this example, the customisation that I am looking for is to use a radio
 widget, and to remove the 'empty value' (defaults to '')
 In order to do so I have to redefine the home_delivery form field, which
 means I have to redefine both the choices *and* the label.

 If another developer comes along and changes the verbose_name for the
 model, they'll (might) be stumped as to why the form label isn't changing.

 I propose being allowed to specify the form in the model, so I could
 replace all of this with:

 {{{
 models.py

 class MyModel(models.Model):
 HOME_DELIVERY = (
 (True, _(u"Home Delivery)),
 (False, _(u"Pickup (free)")),
 )
 home_delivery = models.BooleanField(verbose_name="Pickup/Home
 Delivery",
  choices=HOME_DELIVERY, help_text="Something",
 blank=False,
  field=forms.ChoiceField(empty_label=None,
 widget=forms.RadioSelect()))
 }}}

 Cheers

-- 
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/063.5e644d682a0895cf8e471f577359402f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.