If it is by design - it is ok. I thought that I just can't find
information *how* to do it. Thanks for your time & effort.

On Jun 25, 3:19 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-06-24 at 22:49 +0000, l5x wrote:
> > This is a great stuff and I'm really glad that you show me that, but I
> > still wonder if it is possible to do sth like that in a model ;-)
>
> No, it isn't possible and that's by design. Here's the reasoning behind
> why we are doing it the way we are:
>
> In the general case ,tying a particular presentation to the data
> representation isn't a flexible procedure and long-term in medium to
> large projects, not great design practice either: the person responsible
> for creating the form designs has to also edit the code that is part of
> the data representation. We try very hard in Django (and are continually
> smoothing out places as we go along) to keep independent
> responsibilities separate in the code and this includes moving
> presentation information out of models.
>
> We have to make a choice when creating the API here and, as with all
> choices, some use-cases might become a little harder (but never
> impossible) whilst we are making the common and best-practice cases
> easier. In this particular instance, the case where you have a single
> presentation style and are always creating forms directly from a single
> model requires you to write the field names twice sometimes. That's one
> of the trade-offs in the broader design, unfortunately.
>
> Consequently, you can't drop presentation information into the model
> directly. However, you could store a list of that extra information
> mapped to field names in a dictionary and then write a helper function
> that takes your model and that dictionary and creates a form. So if you
> did have a desire to keep the information together, it's possible. You
> just can't hijack the Field class definitions to store it, because that
> would require changing the API (you could write new classes, one for
> each Field that takes the extra information, but at some point the extra
> work to support that might become onerous).
>
> Regards,
> Malcolm


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to