problems with 'formset.__name__' in save_formset()

557 views
Skip to first unread message

hhanse

unread,
Dec 9, 2008, 11:30:27 AM12/9/08
to Django users
hello group,

im a bloody django and python beginner and right now playing arround
with the code provided on http://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser

on storing the entry in the admin following error occur:

AttributeError at /admin/news/post/add/

'CommentFormFormSet' object has no attribute '__name__'

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/news/post/add/
Exception Type: AttributeError
Exception Value:

'CommentFormFormSet' object has no attribute '__name__'

Exception Location: /Users/hhanse/django/pct/../pct/news/admin.py in
save_formset, line 31
Python Executable: /System/Library/Frameworks/Python.framework/
Versions/2.5/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.5.1

some more infos:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/news/post/add/
Django Version: 1.0.2 final
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'tagging',
'pct.news']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'djangologging.middleware.LoggingMiddleware')


Traceback:
File "/Library/Python/2.5/site-packages/django/core/handlers/base.py"
in get_response
86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in root
157. return self.model_page(request, *url.split('/',
2))
File "/Library/Python/2.5/site-packages/django/views/decorators/
cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py"
in model_page
176. return admin_obj(request, rest_of_url)
File "/Library/Python/2.5/site-packages/django/contrib/admin/
options.py" in __call__
191. return self.add_view(request)
File "/Library/Python/2.5/site-packages/django/db/transaction.py" in
_commit_on_success
238. res = func(*args, **kw)
File "/Library/Python/2.5/site-packages/django/contrib/admin/
options.py" in add_view
497. self.save_formset(request, form, formset,
change=False)
File "/Users/hhanse/django/pct/../pct/news/admin.py" in save_formset
31. if formset.__name__ == 'CommentInline':

Exception Type: AttributeError at /admin/news/post/add/
Exception Value: 'CommentFormFormSet' object has no attribute
'__name__'

i can't find the matter for this - please help!

Rajesh Dhawan

unread,
Dec 9, 2008, 1:09:28 PM12/9/08
to Django users

> im a bloody django and python beginner and right now playing arround
> with the code provided onhttp://code.djangoproject.com/wiki/CookBookNewformsAdminAndUser
>
> on storing the entry in the admin following error occur:
>
> AttributeError at /admin/news/post/add/
>
> 'CommentFormFormSet' object has no attribute '__name__'

Replace the following line:
if formset.__name__ == 'CommentInline':

with the line:
if formset.model == Comment:

I have updated this cook book entry with the above fix.

-Rajesh D
Reply all
Reply to author
Forward
0 new messages