#14496: Conflict between ModelForm.Meta.exclude and ModelAdmin.readonly 
attributes
-------------------------------------------------------------------+--------
 Reporter:  msgre_valise                                           |       
Owner:  nobody    
   Status:  new                                                    |   
Milestone:            
Component:  Contrib apps                                           |     
Version:  1.2       
 Keywords:  ModelForm ModelAdmin readonly_fields exclude conflict  |       
Stage:  Unreviewed
Has_patch:  0                                                      |  
-------------------------------------------------------------------+--------
 I have problem with contrib.admin application. Consider we have demo
 application with this three files:

 demo/models.py:
 {{{
     from django.db import models

     class Demo(models.Model):
         name = models.CharField(max_length=100)
         note = models.TextField(blank=True, null=True)
 }}}


 demo/admin.py:
 {{{
     from django.contrib import admin
     from models import Demo
     from forms import DemoAdminForm

     class DemoAdmin(admin.ModelAdmin):
         readonly_fields = ('name', )
         form = DemoAdminForm

     admin.site.register(Demo, DemoAdmin)
 }}}

 demo/forms.py:
 {{{
     from django import forms
     from models import Demo

     class DemoAdminForm(forms.ModelForm):
         class Meta:
             model = Demo
             exclude = ('note', )
 }}}

 If I go to administration, and edit some Demo object, I see two fields:
 editable Note and readonly Name. But! I should see only readonly Name
 (because I use own ModelForm class which excluded note field). Try to
 comment line "readonly_fields = ('name', )" at admin.py file. You will
 see, that in this situation (no readonly attribute on ModelAdmin) Django
 correctly accept Meta class on ModelForm and exclude field Note.

 I think that there is a problem in the way, how Django construct ModelForm
 class. It don't respect Meta classes in Form, if there is at same time
 readonly attribute on ModelAdmin.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14496>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to