#34329: django-formset new app - i am facing the issue Uncaught (in promise)
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the
JSON data
-----------------------------+--------------------------------------
     Reporter:  Sasikumar K  |                    Owner:  nobody
         Type:  Bug          |                   Status:  new
    Component:  Forms        |                  Version:  4.1
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  0            |      Needs documentation:  1
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+--------------------------------------
Description changed by Sasikumar K:

Old description:

> I am new to django . while i am trying to use django-formset third party
> app in my form modelchoice control change event  show the error -
> Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at
> line 1 column 1 of the JSON data - i have spent 6 hours i could not fix
> the error.

New description:

 I am new to django . while i am trying to use django-formset third party
 app in my form modelchoice control change event  show the error -
 Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at
 line 1 column 1 of the JSON data - i have spent 6 hours i could not fix
 the error.




 form.py

 class OfficedetForm(forms.ModelForm):

     office_logo = fields.FileField(
         label="Office Logo",
         widget=UploadedFileInput,
         required=True,
     )

     office_gender_type = forms.ModelChoiceField(
         queryset=OFFICE_GENDER_TYPE_CHOICE.objects.all(),
         widget=Selectize(

             placeholder="Choose Gender",
         ),
     )

     office_mgnt_type = forms.ModelChoiceField(
         queryset=OFFICE_MGNT_TYPE_CHOICE.objects.all(),
         widget=Selectize(

             placeholder="Choose Management",
         ),
     )

     office_class_level = forms.ModelChoiceField(
         queryset=OfficeClassLevel.objects.all(),
         widget=Selectize(

             placeholder="Choose Class Level",
         ),
     )

     office_place = forms.ModelChoiceField(
         queryset=Places.objects.all(),
         widget=Selectize(
             search_lookup='placename__icontains',
             placeholder="Choose Place",

         ),
     )

     office_type = forms.ChoiceField(
         choices=[ ('SCHOOL','SCHOOL'),
         ('ADMIN','ADMIN'),],
         widget=Selectize,
     )


     default_renderer = FormRenderer(
         form_css_classes='row',
         field_css_classes={
             '*': 'mb-2 col-12',
             "office_code": 'mb-2 col-2',
             "office_name": 'mb-2 col-4',
             "office_mail": 'mb-2 col-3',
             "office_place": 'mb-2 col-3',
              '*': 'mb-2 col-12',
             "office_gender_type": 'mb-2 col-3',
             "office_mgnt_type": 'mb-2 col-3',
             "office_class_level": 'mb-2 col-3',
             "office_type": 'mb-2 col-3',

              '*': 'mb-2 col-12',
             "office_tanno": 'mb-2 col-4',
             "office_udisecode": 'mb-2 col-4',
             "office_logo": 'mb-2 col-4',


             }
             )
     class Meta:
         model = Officedet
         fields = ["office_code",
 "office_name",
 "office_mail",
 "office_place",
 "office_gender_type",
 "office_mgnt_type",
 "office_class_level",
 "office_type",
 'office_tanno',
 'office_udisecode',
 "office_logo",
 ]


 views.py


 class OfficeDetailCreateView(AdminUserTypeAuthMixin,FileUploadMixin,
 FormViewMixin, LoginRequiredMixin, CreateView):
     model = Officedet
     template_name = 'home/crud/crud_template.html'
     form_class = OfficedetForm
     success_url = reverse_lazy('office_list_view')  # or whatever makes
 sense
     extra_context = {
         'pagetitle':'Office Creation'
         }

 page.html

 {% extends "layouts/masterpage-formset.html" %}
 {% block pagecontent %}
 {% load render_form from formsetify %}
 <django-formset endpoint="{{ request.path }}" csrf-token="{{ csrf_token
 }}">
   {% render_form form %}


   <div class="{{ button_css_classes }}">
     <button type="button" click="disable -> confirm('Do want to Submit ?')
 -> spinner -> submit -> okay(500) -> proceed" auto-disable="{{
 auto_disable|yesno:'true,false' }}" class="btn btn-primary">Submit<span
 class="ms-2 dj-button-decorator"><i class="bi bi-
 send"></i></span></button>
     <button type="button" click="reset" class="ms-2 btn btn-
 warning">Reset</button>
     <button click="proceed('/office_list_view/')" class="btn btn-
 info">Back to list</button>

 </div>
 </django-formset>
 {% endblock pagecontent %}

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34329#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701863a2e8f9e-1b90a404-5ea8-4662-8fa4-728905104f4d-000000%40eu-central-1.amazonses.com.

Reply via email to