Thanks, working :)
def __init__(self, *args, **kwargs):
super(MealModelForm, self).__init__(*args, **kwargs)
try:
instance = kwargs['instance']
self.fields['price'].initial = instance.price()
except (KeyError, AttributeError):
pass
On Tue, Jun 28, 2011 at 10:27 AM, Marc Aymerich wrote:
> On Mon, Jun 27, 2011 at 11:03 PM, momo2k wrote:
>> Hello,
>>
>> Is there a way to set dynamic default values for custom fields in the
>> admin?
>>
>> Description of the problem:
>>
>> #
On Mon, Jun 27, 2011 at 11:03 PM, momo2k wrote:
> Hello,
>
> Is there a way to set dynamic default values for custom fields in the
> admin?
>
> Description of the problem:
>
> # models.py
> # there are two models
> class Meal(models.Model):
> name = ...
>
> def
Hello,
Is there a way to set dynamic default values for custom fields in the
admin?
Description of the problem:
# models.py
# there are two models
class Meal(models.Model):
name = ...
def check_new_price(self, price):
# checks if the price is new and creates a new price if
4 matches
Mail list logo