Marek Stępniowski wrote: > How to create a field that is not stored in database, but is visible > in Django newforms-admin? (I'm assuming there is a way) > > I would like to define a field which acts as a kind of proxy. Setting > and getting value of this field actually runs some defined operation > (for example executes custom SQL query) and returns it's results. This > field has a related form field which is visible in Django > newforms-admin among the form fields for other fields of containing > model.
Nothing requires there to be a 1-to-1 mapping of form to model. In fact I've made a forms that have no model at all. > As I'm using newforms-admin, I could add the form field to the > ModelForm of my model in ModelAdmin and define custom save method for > this form, which would execute a defined operation. But I want to have > this functionality in two my different projects, and this approach > would not be DRY. Put functionality in base class(es) and or library that both projects inherit/use. I would be wary of putting functionality other than data collection/validation/munging into a form. "save" sounds like it needs to be in a Model or Manager. > So is there a way to create such model field? Or maybe there is a > better way to achieve what I want? Please help. Know about Python properties? http://www.python.org/download/releases/2.2.3/descrintro/#property They are exactly what I'd use to implement "Setting and getting value of this field actually runs some defined operation" -- Norman J. Harman Jr. Senior Web Specialist, Austin American-Statesman ___________________________________________________________________________ You've got fun! Check out Austin360.com for all the entertainment info you need to live it up in the big city! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---