On Jan 29, 12:35 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Wed, 2009-01-28 at 04:27 -0800, Vinay Sajip wrote:
> > I'd like to attach some user-defined meta-information to individual
> > model fields and have it also be available in the corresponding form
> > fields. Ideally, I'd have liked to have a keyword arg on the fields...
>
> > class MyModel(models.Model):
> >     name = models.CharField(max_length=100, info=some_object)
> >     active = models.BooleanField(info=some_other_object)
>
> > Ideally, this information would be available in the corresponding form
> > field.
>
> > What's the best way of achieving this DRY-ly?
>
> Creating form and model field subclasses. You'll need to override the
> model field's __init__ method to handle the extra kwarg and the
> formfield() method.
>

I was hoping there was another way. Of course subclassing's not hard
to do, but it means doing it for every field class. I was looking at
moving an application over from SQLAlchemy, which offers this feature
both for models and fields.

Thanks,

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

Reply via email to