Hi Alex,
Sorry it took me a while to reply, only just saw the thread update.
Yeah, thinking about it, the previous method probably wouldn't have
worked due to the way Django handles the db model objects.
Okay, in this particular case, I would suggest re-thinking the way this
is being done.
Here is an approach I have used. I can't tell from your question
whether this will help you or not.
class AccountEntryModelForm(ModelForm):
def __init__(self, organization=None, operation=None, *args,
**kwargs):
super(ModelForm, self).__init__(*args, **kwargs)
Hi Cal!
Thank you very much for your reply and advice, but unfortunately it doesn't
work. It seems like in __init__ method we can't re-assign the choices. Even
if I try:
class Something(models.Model):
def __init__(self, *args, **kwargs):
_choices = ((SomeValue, 'SomeString'), )
Hi Alex,
I think this is what you might be looking for.
class Something(models.Model):
def __init__(self, *args, **kwargs):
if kwargs.has_key('range_marks'):
_choices = kwargs.get('range_marks')
del kwargs['range_marks']
else:
_choices =
Hi!
I got such kind of problem.
I'd like to define the tuple(list) of choices option at the moment of
instance created on the fly
In the future these choices will not change.
Hence I've found just one way to do it - override __init__() of my model
and
pass there the particular predefined list of
5 matches
Mail list logo