This is a strange way to do things - but all you need to do is to add a
template for loop in the javascript part of your template. For example:

<script type="text/javascript">

 {% for gsp in apply_gsp_model %}

   var value1 = {% gsp.id %};

 {% endfor %}

</script>


What will happen then is that the iteration will create that line for each
gsp in your apply_gsp_model qs.

Regards,

Andréas


Den fre 6 dec. 2019 kl 20:42 skrev Dilipkumar Noone <n.dil...@gmail.com>:

> Hi,
>
> I  have a model named ApplyGSP in models.py.
>
> *In my views.py:*
>
> apply_gsp_model = ApplyGSP.objects.all()
>
> context = {'form': form,'apply_gsp_model':apply_gsp_model, 'Message': 
> message, 'action': action}
> if action == 'edit':
>     print("action is edit")
>     return render(request, 'EditApplyGSP.html', context)
> else:
>     print("action is submit")
>     return render(request, 'ApplyGSP.html', context)
>
>
> I want to traverse through the model instance in javascript using django 
> template.
>
>
> can some one suggest how to traverse through django queryset and access the 
> database fields inside java script.
>
>
> <script type="text/javascript">
>
>
> </script>
>
>
> Regards,
>
> N.Dilip kumar.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/789645b6-91f2-40ea-b4c0-44580fb2bdef%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/789645b6-91f2-40ea-b4c0-44580fb2bdef%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCc9xZBV4%3DUL_ShKSMRpftrmFdZgDP3VXfetwTexpYjqPA%40mail.gmail.com.

Reply via email to