I had tried earlie what you suggested but it didnt solved my problem because it only assigns initial values to new records and not to existents ones.
But i finally figured out a small change on code which does it well. I just replaced "self.fields['your_field'].initial" with "self.initial['text']".
Thanks again! Regards,
On Sun, Apr 1, 2012 at 4:55 PM, Marc Aymerich <glicerinu@gmail.com> wrote:
On Sun, Apr 1, 2012 at 9:42 PM, Pedro Vasconcelos <pedro@pedrorafa.com> wrote:sure, you can do it on form __init__ method
> Hello Marc!
>
> Thanks for replying. Unfortunately I cant realised how to get the current
> value, change it and populate the form using a ModelForm. I've tried it
> actually.
>
something like
class YourForm(ModelForm):
def __init__(self, *args, **kwargs):
super(YourForm, self).__init__(*args, **kwargs)
self.fields['your_field'].initial = your_postprocess_method()
also you should override the save form method in order to "reverse"
the postprocess and save the data in raw format.
--
Marc
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Pedro Vasconcelos
85 8767.1843
ptronico (skype)
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment