Changes between Version 1 and Version 2 of Ticket #34329


Ignore:
Timestamp:
Feb 10, 2023, 1:16:15 AM (21 months ago)
Author:
Sasikumar K
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34329 – Description

    v1 v2  
    11I 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.
    22
     3
     4
     5
     6form.py
     7
     8class OfficedetForm(forms.ModelForm):
     9   
     10    office_logo = fields.FileField(
     11        label="Office Logo",
     12        widget=UploadedFileInput,
     13        required=True,
     14    )
     15
     16    office_gender_type = forms.ModelChoiceField(
     17        queryset=OFFICE_GENDER_TYPE_CHOICE.objects.all(),
     18        widget=Selectize(
     19           
     20            placeholder="Choose Gender",
     21        ),
     22    )
     23
     24    office_mgnt_type = forms.ModelChoiceField(
     25        queryset=OFFICE_MGNT_TYPE_CHOICE.objects.all(),
     26        widget=Selectize(
     27           
     28            placeholder="Choose Management",
     29        ),
     30    )
     31
     32    office_class_level = forms.ModelChoiceField(
     33        queryset=OfficeClassLevel.objects.all(),
     34        widget=Selectize(
     35           
     36            placeholder="Choose Class Level",
     37        ),
     38    )
     39
     40    office_place = forms.ModelChoiceField(
     41        queryset=Places.objects.all(),
     42        widget=Selectize(
     43            search_lookup='placename__icontains',
     44            placeholder="Choose Place",
     45           
     46        ),
     47    )
     48
     49    office_type = forms.ChoiceField(
     50        choices=[ ('SCHOOL','SCHOOL'),
     51        ('ADMIN','ADMIN'),],
     52        widget=Selectize,
     53    )
     54
     55
     56    default_renderer = FormRenderer(
     57        form_css_classes='row',
     58        field_css_classes={
     59            '*': 'mb-2 col-12',
     60            "office_code": 'mb-2 col-2',
     61            "office_name": 'mb-2 col-4',
     62            "office_mail": 'mb-2 col-3',
     63            "office_place": 'mb-2 col-3',
     64             '*': 'mb-2 col-12',
     65            "office_gender_type": 'mb-2 col-3',
     66            "office_mgnt_type": 'mb-2 col-3',
     67            "office_class_level": 'mb-2 col-3',
     68            "office_type": 'mb-2 col-3',
     69
     70             '*': 'mb-2 col-12',
     71            "office_tanno": 'mb-2 col-4',
     72            "office_udisecode": 'mb-2 col-4',
     73            "office_logo": 'mb-2 col-4',
     74
     75
     76            }
     77            )
     78    class Meta:
     79        model = Officedet
     80        fields = ["office_code",
     81"office_name",
     82"office_mail",
     83"office_place",
     84"office_gender_type",
     85"office_mgnt_type",
     86"office_class_level",
     87"office_type",
     88'office_tanno',
     89'office_udisecode',
     90"office_logo",
     91]
     92
     93
     94views.py
     95
     96       
     97class OfficeDetailCreateView(AdminUserTypeAuthMixin,FileUploadMixin, FormViewMixin, LoginRequiredMixin, CreateView):
     98    model = Officedet
     99    template_name = 'home/crud/crud_template.html'
     100    form_class = OfficedetForm
     101    success_url = reverse_lazy('office_list_view')  # or whatever makes sense
     102    extra_context = {
     103        'pagetitle':'Office Creation'
     104        }
     105
     106page.html
     107
     108{% extends "layouts/masterpage-formset.html" %}
     109{% block pagecontent %}
     110{% load render_form from formsetify %}
     111<django-formset endpoint="{{ request.path }}" csrf-token="{{ csrf_token }}">
     112  {% render_form form %}
     113
     114 
     115  <div class="{{ button_css_classes }}">
     116    <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>
     117    <button type="button" click="reset" class="ms-2 btn btn-warning">Reset</button>
     118    <button click="proceed('/office_list_view/')" class="btn btn-info">Back to list</button>
     119   
     120</div>
     121</django-formset>
     122{% endblock pagecontent %}
     123       
Back to Top