Django Crispy Forms Rendering Issue 'cannot convert dictionary update sequence element #0 to a sequence' -


struggling figure 1 out. i've seen several issues error code shows seem have data not being passed context template render. know data getting through template. crispy forms must doing behind scenes throwing me off? weird thing literally worked 20 minutes ago. don't know have changed have affected this.

here view:

class contactlistview(view):      template = 'support_tracker/contact_list.html'      def get(self,request,*args,**kwargs):         staff_id = kwargs.pop('staff_id',false)          if staff_id:             staff = staff.objects.get(pk=staff_id)         else:             staff = request.user.staff         contact_list = staff.contacts.all()          search_term = request.get.get('search_term',false)         sort_by = request.get.get('sort_by',false)         filter_by = request.get.get('filter_by',false)          ##applying search term determine contact_list             ...         ##          ##sorting of contact_list             ....         ##          ##filtering of contact_list             ....         ##          search_form = searchform()         sort_form = contactlistsortform()         filter_form = filterbystageform()          ##pagination determine contacts             ...         ##          context = {         'staff':staff,         'contacts':contacts,         'search_form':search_form,         'sort_form':sort_form,         'filter_form':filter_form,         'filter_by':filter_by,         'search_term':search_term,         'sort_by':sort_by,         }          print context          return render(request,self.template,context) 

my forms:

##forms.py class searchform(forms.form):     search_term = forms.charfield(max_length=30,label='')      def __init__(self,*args,**kwargs):         super(searchform,self).__init__(*args,**kwargs)         self.helper = formhelper()         self.helper.form_class = 'form-inline'         self.helper.form_method = 'get'         self.helper.field_template = 'bootstrap3/layout/inline_field.html'         self.helper.layout = layout(             inlinefield('search_term',placeholder='search'),             submit('','go',css_class='btn btn-primary'),             )  class filterbystageform(forms.form):         filter_by = forms.choicefield(choices=get_stage_option_list(),required=false)      def __init__(self,*args,**kwargs):         super(filterbystageform,self).__init__(*args,**kwargs)         self.helper = formhelper()         self.helper.form_class = 'form-inline'         self.helper.form_method = 'get'         self.helper.field_template = 'bootstrap3/layout/inline_field.html'         self.helper.layout = layout(             inlinefield('filter_by',placeholder='filter by'),             submit('','filter',css_class='btn btn-primary'),             )  class contactlistsortform(forms.form):     sort_by = forms.choicefield(choices=(##options),required=false)      def __init__(self,*args,**kwargs):         super(contactlistsortform,self).__init__(*args,**kwargs)         self.helper = formhelper()         self.helper.form_class = 'form-inline'         self.helper.form_method = 'get'         self.helper.field_template = 'bootstrap3/layout/inline_field.html'         self.helper.layout = layout(             inlinefield('sort_by',placeholder='sort by'),             submit('','sort',css_class='btn btn-primary'),             ) 

my template:

{% extends 'co_tools/base.html' %} {% load crispy_forms_tags %}  {% block content %} <div class='container'>     <div class='col-md-3 well'>         <h3><u>search:</u></h3>           ## part trips up. if take forms out, rest of page loads fine         {% crispy search_form %}         {% crispy sort_form %}         {% crispy filter_form %}           <a href='/support/new_contact/' class='btn btn-primary'>new contact</a>     </div>      ...body...  </div> {% endblock content %} 

the full traceback

request method: request url: http://127.0.0.1:8000/support/contact_list/  django version: 1.10.2 python version: 2.7.11 installed applications: ['django.contrib.admin',  'django.contrib.auth',  'django.contrib.contenttypes',  'django.contrib.sessions',  'django.contrib.messages',  'django.contrib.staticfiles',  'crispy_forms',  'support_tracker',  'donor_reports',  'staff',  'financial_reports'] installed middleware: ['django.middleware.security.securitymiddleware',  'django.contrib.sessions.middleware.sessionmiddleware',  'django.middleware.common.commonmiddleware',  'django.middleware.csrf.csrfviewmiddleware',  'django.contrib.auth.middleware.authenticationmiddleware',  'django.contrib.messages.middleware.messagemiddleware',  'django.middleware.clickjacking.xframeoptionsmiddleware']   template error: in template c:\...\project\support_tracker\templates\support_tracker\contact_list.html, error @ line 8    cannot convert dictionary update sequence element #0 sequence   1 : {% extends 'co_tools/base.html' %}    2 : {% load crispy_forms_tags %}    3 :     4 : {% block content %}    5 : <div class='container'>    6 :  <div class='col-md-3 well'>    7 :      <h3><u>search:</u></h3>    8 :       {% crispy form %}     9 :      <a href='/support/new_contact/' class='btn btn-primary'>new contact</a>    10 :     </div>    11 :     <div class='col-md-9'>    12 :         <table class='table table-condensed table-hover'>    13 :             <thead>    14 :                 <th>contact name</th>    15 :                 <th>phone number</th>    16 :                 <th>email</th>    17 :                 <th>street address</th>    18 :                 <th>city</th>   traceback:  file "c:\...\project\env\lib\site-packages\django\core\handlers\exception.py" in inner   39.             response = get_response(request)  file "c:\...\project\env\lib\site-packages\django\core\handlers\base.py" in _get_response   187.                 response = self.process_exception_by_middleware(e, request)  file "c:\...\project\env\lib\site-packages\django\core\handlers\base.py" in _get_response   185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)  file "c:\...\project\env\lib\site-packages\django\views\generic\base.py" in view   68.             return self.dispatch(request, *args, **kwargs)  file "c:\...\project\env\lib\site-packages\django\views\generic\base.py" in dispatch   88.         return handler(request, *args, **kwargs)  file "c:\...\project\support_tracker\views.py" in   185.      return render(request,self.template,context)  file "c:\...\project\env\lib\site-packages\django\shortcuts.py" in render   30.     content = loader.render_to_string(template_name, context, request, using=using)  file "c:\...\project\env\lib\site-packages\django\template\loader.py" in render_to_string   68.     return template.render(context, request)  file "c:\...\project\env\lib\site-packages\django\template\backends\django.py" in render   66.             return self.template.render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render   208.                     return self._render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in _render   199.         return self.nodelist.render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render   994.                 bit = node.render_annotated(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render_annotated   961.             return self.render(context)  file "c:\...\project\env\lib\site-packages\django\template\loader_tags.py" in render   174.         return compiled_parent._render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in _render   199.         return self.nodelist.render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render   994.                 bit = node.render_annotated(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render_annotated   961.             return self.render(context)  file "c:\...\project\env\lib\site-packages\django\template\loader_tags.py" in render   70.                 result = block.nodelist.render(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render   994.                 bit = node.render_annotated(context)  file "c:\...\project\env\lib\site-packages\django\template\base.py" in render_annotated   961.             return self.render(context)  file "c:\...\project\env\lib\site-packages\crispy_forms\templatetags\crispy_forms_tags.py" in render   215.         c = self.get_render(context)  file "c:\...\project\env\lib\site-packages\crispy_forms\templatetags\crispy_forms_tags.py" in get_render   126.         response_dict = self.get_response_dict(helper, context, is_formset)  file "c:\...\project\env\lib\site-packages\crispy_forms\templatetags\crispy_forms_tags.py" in get_response_dict   160.         attrs = helper.get_attributes(template_pack=self.template_pack)  file "c:\...\project\env\lib\site-packages\crispy_forms\helper.py" in get_attributes   364.         if self.form_action:  file "c:\...\project\env\lib\site-packages\crispy_forms\helper.py" in form_action   237.             return reverse(self._form_action)  file "c:\...\project\env\lib\site-packages\django\urls\base.py" in reverse   91.     return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))  file "c:\...\project\env\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix   344.             self._populate()  file "c:\...\project\env\lib\site-packages\django\urls\resolvers.py" in _populate   217.                                     dict(defaults, **pattern.default_kwargs),  exception type: typeerror @ /support/contact_list/ exception value: cannot convert dictionary update sequence element #0 sequence 

i have no idea causing this. appreciated.

ok solved issue. have no clue why particular bit of code causing problem though.

in urls.py, had added following 4 url expressions...

from django.conf.urls import url, include import views

urlpatterns = [      ...     #meeting urls     url(r'^record_meeting/(?p<meeting_id>[0-9]+)/',views.editmeetingview.as_view(),{'record':true}),     url(r'^record_meeting/$',views.editmeetingview.as_view(),{'record':true}),     url(r'^edit_meeting/(?p<meeting_id>[0-9]+)/',views.editmeetingview.as_view(),{'record':false}),     url(r'^add_meeting/$',views.editmeetingview.as_view()), ] 

the fourth 1 url(r'^add_meeting/$',views.editmeetingview.as_view(),{'record':false}), apparently, based on trial , error, causing issue. after removing additional arguments, problem went away. know why issue in first place? still don't understand.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -