Opened 16 years ago
Closed 16 years ago
#8899 closed (fixed)
Admin "exclude" option should accept both lists and tuples
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.0 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
On http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin
at the exclude example it says:
class AuthorAdmin(admin.ModelAdmin): fields = ('name', 'title') class AuthorAdmin(admin.ModelAdmin): exclude = ('birth_date',)
But it should be
class AuthorAdmin(admin.ModelAdmin): fields = ['name', 'title'] class AuthorAdmin(admin.ModelAdmin): exclude = ['birth_date',]
Attachments (1)
Change History (8)
comment:1 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
Actually, I followed the docs and used a tuple and received the following error:
Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py" in get_response
- response = callback(request, *callback_args, callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in root
- return self.model_page(request, *url.split('/', 2))
File "/Library/Python/2.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
- response = view_func(request, *args, kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in model_page
- return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/options.py" in call
- return self.add_view(request)
File "/Library/Python/2.5/site-packages/django/db/transaction.py" in _commit_on_success
- res = func(*args, kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/options.py" in add_view
- ModelForm = self.get_form(request)
File "/Library/Python/2.5/site-packages/django/contrib/admin/options.py" in get_form
- "exclude": exclude + kwargs.get("exclude", []),
Exception Type: TypeError at /lifestyle/admin/lifestyle/post/add/
Exception Value: can only concatenate tuple (not "list") to tuple
As a list, no errors are generated. If it's supposed to allow both types, then that functionality is broken, so one of Django or the docs needs to be fixed.
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
The code is wrong in this case. It should be fixed.
comment:4 by , 16 years ago
Component: | Documentation → django.contrib.admin |
---|---|
Summary: | Type: () should be [] → Admin "fields" and "excludes" should accept both lists and tuples |
Changed the title to something less cryptic.
comment:5 by , 16 years ago
Summary: | Admin "fields" and "excludes" should accept both lists and tuples → Admin "exclude" option should accept both lists and tuples |
---|
Added patch, and also changed summary as only "exclude" is problematic ("fields" already accepts both types).
comment:6 by , 16 years ago
Has patch: | set |
---|
comment:7 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
This was fixed in passing in [9086].
You can use any python sequence type. So tuples are OK.