It's not easy to understand what you are trying to do and in which way it
is failing. It would require us setting up a test project.
I am assuming you want that the Admin display a form with a field for each
of Mymodel field plus the myextra_field attribute and what you get is
either only the name fields and maybe the myextra_field. If that not the
case, plus give us more information about your problem.

MymodelAdmin.fields is overriding MyForm.fields. If you are curious, it's
around line 594 of django/contrib/admin/options.py. If fields is set,
get_fields return that. Else, it will return the form base_fields and the
modeladmin readonly_fields.



2016-09-08 18:41 GMT+02:00 Luis Zárate <luisz...@gmail.com>:

> Hi,  I am trying to do something like
>
>
> class MyForm(forms.ModelForm):
>      myextra_field = forms.IntegerField()
>
>     class Meta:
>           models = Mymodel
>           fields = '__all__'
>
> class MymodelAdmin(admin.ModelAdmin):
>       form = MyForm
>       fields = ["name", 'myextra_field']
>
>     def save(self, *args, **kwargs)
>         do something with myextra_field
>
>
> I know that is possible to specify readonly_fields and fields works but in
> readonly mode that is not what i want.
>
> So is there any way to have extra form fields in admin.ModelAdmin in edit
> mode?
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/django-users/CAG%2B5VyNVmNPzjkd-9bV_j35%2BNn5PYdjvMzi6GQ
> v%2BhaDFZLrbug%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAG%2B5VyNVmNPzjkd-9bV_j35%2BNn5PYdjvMzi6GQv%2BhaDFZLrbug%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTZHhNTu1MXqCq_YXNxbKqX5SjCXeH3VJvV8Me_zmXpLXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to