Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-16 Thread Jacob Kaplan-Moss

On Fri, Jan 16, 2009 at 5:06 AM, Flavio Curella
 wrote:
> Wouldn't it be more granular to allow the overrides on the field name
> basis? something like:

Hm, I think that's a separate issue: the goal of the patch is to
easily make "mixins" providing custom widgets (etc.) easier. There's
already a couple of easy ways to use a custom form field for a
particular model field: you can extend ``formfield_for_dbfield`` and
dispatch based on ``db_field.name``, or use a custom ModelForm. Of
those, I'd use the second, btw.

Jacob

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



Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-16 Thread Flavio Curella

sorry, wrong snippets

```
# assume years_range = range(2008, 1900)
formfield_overrides = {
'body': { 'widget': RichTextEditorWidget() },
'birthday': {'widget': SelectDateWidget(years=years_range) },
}
```

maybe this is for yet another option, or we can allow something like
this (ps: i dont really like this way):

```
# assume years_range = range(2008, 1900)
formfield_overrides = {
models.TextField: { 'widget': RichTextEditorWidget() },
'birthday': {'widget': SelectDateWidget(years=years_range) },
}
```

of course with the current patch this is not strictly required, i.e.
you can always subclass a default field on override that. I just would
like to know your thoughts about this.

Thanks,
Flavio.

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



Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-16 Thread Flavio Curella

hi,

I read the patch in #8306, and looks like formfield_overrides allows
to change the default widget only on a field type basis:

```
formfield_overrides = {
models.TextField: {'widget': RichTextEditorWidget},
}
```

Wouldn't it be more granular to allow the overrides on the field name
basis? something like:
```
# assume years_range = range(2008, 1900)
formfield_overrides = { 'body': RichTextEditorWidget(), 'birthday':
SelectDateWidget(years=years_range) }
```

note that I don't pass class anymore but instances, in order to allow
some configuration.



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



Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-15 Thread Jacob Kaplan-Moss

On Thu, Jan 15, 2009 at 6:43 PM, Brian Rosner  wrote:
> I think this definitely the right direction. An outstanding admin
> ticket that this is touching very heavily on is #3987. You've done a
> really good job making the right abstractions. I went a step further
> and figured this should be included as it does change the method
> signature [2].

Ah, good catch.

Note to self: when in doubt, pass around the request in the admin.
It's almost always a good idea.

Jacob

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



Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-15 Thread Brian Rosner

On Thu, Jan 15, 2009 at 2:56 PM, Jacob Kaplan-Moss  wrote:
> I'm pretty happy with the approach, but honestly I don't use the admin
> all that hard so I'm not 100% confidant that the design is perfect. So
> I'd love a quick review of the latest patch on #8306 (also available
> on github: 
> http://github.com/jacobian/django/commits/trac/8306-admin-field-overrides).

I think this definitely the right direction. An outstanding admin
ticket that this is touching very heavily on is #3987. You've done a
really good job making the right abstractions. I went a step further
and figured this should be included as it does change the method
signature [2].

[1]: http://code.djangoproject.com/ticket/3987
[2]: 
http://github.com/brosner/django/commit/d6c0a47be4a2ea7743c9e90a4accd43993b4f5bd

-- 
Brian Rosner
http://oebfare.com

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



Re: Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-15 Thread Alex Gaynor
On Thu, Jan 15, 2009 at 4:56 PM, Jacob Kaplan-Moss wrote:

>
> Hi folks --
>
> Building on some work James did, I've cleaned up formfield_for_dbfield
> to make field overrides easier in the admin.
>
> I'm pretty happy with the approach, but honestly I don't use the admin
> all that hard so I'm not 100% confidant that the design is perfect. So
> I'd love a quick review of the latest patch on #8306 (also available
> on github:
> http://github.com/jacobian/django/commits/trac/8306-admin-field-overrides
> ).
>
> The patch is pretty small so hopefully it makes sense, but questions
> of course welcome.
>
> Jacob
>
> >
>
It looks good by me and gives me an easy entry point to use for #9976[1].

Alex


[1]: http://code.djangoproject.com/ticket/9976
-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Sanity check #8306 (cleaning up formfield_for_dbfield), please

2009-01-15 Thread Jacob Kaplan-Moss

Hi folks --

Building on some work James did, I've cleaned up formfield_for_dbfield
to make field overrides easier in the admin.

I'm pretty happy with the approach, but honestly I don't use the admin
all that hard so I'm not 100% confidant that the design is perfect. So
I'd love a quick review of the latest patch on #8306 (also available
on github: 
http://github.com/jacobian/django/commits/trac/8306-admin-field-overrides).

The patch is pretty small so hopefully it makes sense, but questions
of course welcome.

Jacob

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