Hey everyone,
am pretty new to Django and Python in general.
I seem not be able to let the 'initial' value of a form-field be
calculated by its parent form.
I'd like to do sth like this:
class AbstractForm(forms.Form):
some_attr = "foo"
def some_method(self):
if self.some_attr == "foo": return "foo"
return "Something else..."
some_field = forms.CharField(initial=self.some_method())
..but obviously I cant access 'self' when declaring some_field.. and
obviously I have yet to learn a lot about Python oop :)
Fyi. I do not want to initiate form defaults like
f = MyForm(initial=...) in my views since I'd have to repeat that in
each view.
I'd rather do things like this lateron:
class ConcreteForm(AbstractForm):
some_attr = "bar"
Somebody willing to enlighten me?
Thx a lot & cheers
carsten
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---