Friday, May 1, 2020

Django dropdown data display issues in the control

Hi,

I am a beginner in Django and want to developing one assignment in django.

Now, I am created one model category and subcategory. Based on category populate the data sub-category and data have saved like the below format.

Category =  Operations

Subcategory = Category1,Category2,Category3,Category4

Same like other categories.
I want to display data in index.html page selection option like

Subcategory:  Category1
                     Category2
                     Category3

e.g. I looking like this .


I tried to use split function but it is not working. Please help us its a really appreciated.

My Code: How to split the values.


      <select name="subcatsname">                

        {% for subcat in all_subcats_keys %}
        
        <option value="{{subcat.subcategory }}">{{subcat.subcategory }}</option>       

        {% endfor %}
        
      </select>


Current Scenario, data display likes



Thanks & Regards
Ajeet Kumar Gupt
+91-9311232332

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BTqRsv%2BRKe5MneRxSbH_TpGw4j9Wt65xA-JNNpsG%2Bx_VE0Wug%40mail.gmail.com.

No comments:

Post a Comment