On Feb 24, 10:48 pm, "piz...@gmail.com" <piz...@gmail.com> wrote:
> Hello,
>
> I'm trying to show the result of a model method in the admin view. My  
> problem is that the dev server crashes with this error:
>
> Exception Value:        'PersonaAdmin.fieldsets[3][1]['fields']' refers to  
> field 'age' that is missing from the form.
>
> I have the method 'age' inside a class named 'Persona', and I show it  
> just putting it in admin.py (following the instructions in Tutorial 1  
> and 2)
>
> Code:
>
> ---models.py
> <class here>
>      def age(self):
>          today = datetime.date.today()
>          birth = self.birth_date
>          diff = today - birth
>          years = diff/365
>          return years
>
> ---admin.py
> class PersonaAdmin(admin.ModelAdmin):
>      fieldsets = [
>          ('Datos personales', {'fields': \
>              [('name', 'avatar'),
>              ('lastname', 'nickname'),
>              ('dni', 'birth_date'), 'age']}),
> <rest of fieldset and PersonaAdmin class here>
>
> Sorry if it's a stupid question, but i'm just learning Django.

You can't use a method there. The form is for editing fields - it
doesn't make sense to edit the result of a method call.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to