Django

Code

Ticket #7188 (closed: invalid)

Opened 4 days ago

Last modified 4 days ago

FieldDoesNotExist Error because of the fields tuple inside the Admin class

Reported by: Vali <vali.lungu@gmail.com> Assigned to: nobody
Component: Admin interface Version: SVN
Keywords: models admin fields Cc:
Triage Stage: Unreviewed Has patch: 0
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

I'm currently having a Menu model with an Admin class. Inside the admin class, I'm defining the fields tuple in order to have all the model fields displayed in a nice, ergonomic manner. The Admin class looks like this:

    class Admin:
            fields = ( 
                (None, { 
                    'fields': ('name', 'description', 'linked_page', 'linked_resource', 'menu_group', 'position') 
                }), 
                (_('Language options'), { 
                    'classes': 'collapse', 
                    'fields' : ('language'),
                    'description': _('Language options for each page') 
                }), 
                (_('Advanced options'), { 
                    'classes': 'collapse', 
                    'fields' : ('status', 'pub_date'),
                    'description': 'Some extra advanced options for each menu entry' 
                }), 
            ) 
            list_per_page = 10
            list_display = ('name', 'position', 'description', 'linked_page', 'linked_resource', 'menu_group', 'status', 'was_published_today', 'pub_date')         
            list_filter = ['language', 'pub_date', 'status','linked_page', 'menu_group']
            search_fields = ['name', 'description', 'linked_resource']
            date_hierarchy = 'pub_date'
            ordering = ["position"]

As you can see, the fields tuple inside (_('Language options') contains a single element, which is the 'language' field. This configuration brings a


FieldDoesNotExist? at /cms/admin/content/menu/15/ Menu has no field named 'l'


error each time I'm trying to change any of the Menu entries.

It seems that if I'm adding another field, any field, to the fields tuple inside the language options, the error does not occur anymore. So, a tuple like this: 'fields' : ('language', 'name'), would do the trick. However, I cannot do that because the 'name' field already appears and has nothing to do with the language options.

Attachments

Change History

05/07/08 09:50:13 changed by brosner

  • status changed from new to closed.
  • needs_better_patch changed.
  • resolution set to invalid.
  • needs_tests changed.
  • needs_docs changed.

The value for fields in your Language options fieldset is not a tuple. You need a comma at the end. `('langauge',)

05/07/08 09:50:51 changed by brosner

For clarity, that should have read ('language',)


Add/Change #7188 (FieldDoesNotExist Error because of the fields tuple inside the Admin class)




Change Properties
Action