我有一个在提交时不起作用的题词表格
我收到此错误:
** 之后的 reverse() 参数必须是映射,而不是 str
这是我的观点:
def inscription(request, seance_id):
seance = get_object_or_404(Variant, id=seance_id)
inscription_config = {'form_class': InscriptionForm,
'extra_context': {'seance': seance}}
return create_object(request, **inscription_config)
我的表格:
class InscriptionForm(forms.ModelForm):
class Meta:
model = Inscription
def clean(self):
cleaned_data = self.cleaned_data
email = cleaned_data.get("mail")
mail_confirmation = cleaned_data.get("mail_confirmation")
if email != mail_confirmation:
raise forms.ValidationError("Les deux adresses mails doivent correspondre")
return cleaned_data
似乎触发错误的是返回语句中的**inscription_config
但我不知道为什么,从昨天开始我一直在寻找
编辑
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8039/formations/inscription/1/
Django Version: 1.2.5
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
'django.contrib.comments',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'ckeditor',
'constance',
'constance.backends.database',
'custom_flatpages',
'django_extensions',
'django_mobile',
'django_xmlrpc',
'easy_thumbnails',
'gestion_formations',
'file_uploader',
'less',
'mptt',
'contact',
'newsletter',
'pagination',
'south',
'sentry',
'sentry.client',
'indexer',
'paging',
'contentadmin',
'gallerie']
Installed Middleware:
('annoying.middlewares.StaticServe',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'pagination.middleware.PaginationMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
100. response = callback(request, *callback_args, **callback_kwargs)
File "/home/anass/projects/c139_fc_finance/fc_finance/gestion_formations/views/carts.py" in inscription
24. form_class= InscriptionForm
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/create_update.py" in create_object
118. return redirect(post_save_redirect, new_object)
File "/usr/local/lib/python2.7/dist-packages/django/views/generic/create_update.py" in redirect
65. return HttpResponseRedirect(obj.get_absolute_url())
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py" in _curried
55. return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in get_absolute_url
969. return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' % (opts.app_label, opts.module_name), func)(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/__init__.py" in inner
32. return reverse(bits[0], None, *bits[1:3])
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse
351. *args, **kwargs)))
Exception Type: TypeError at /formations/inscription/1/
Exception Value: reverse() argument after ** must be a mapping, not str