Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#7188 closed (invalid)

FieldDoesNotExist Error because of the fields tuple inside the Admin class

Reported by: Vali <vali.lungu@…> Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords: models admin fields
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


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.

Change History (2)

comment:1 Changed 11 years ago by Brian Rosner

Resolution: invalid
Status: newclosed

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

comment:2 Changed 11 years ago by Brian Rosner

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

Note: See TracTickets for help on using tickets.
Back to Top